@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof AminoAcidCompound)) { return false; } AminoAcidCompound them = (AminoAcidCompound) obj; if (toString().equals(them.toString())) { return true; } return getLongName().equals(them.getLongName()); }
public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName, String longName, String description, Float molecularWeight) { super(shortName); setShortName(shortName); setLongName(longName); setDescription(description); setMolecularWeight(molecularWeight); this.compoundSet = compoundSet; }
/** * An adaptor method to return the composition of the 20 standard amino acid in the sequence. * The sequence argument must be a protein sequence consisting of only * non-ambiguous characters. * The composition of an amino acid is the total number of its occurrence, * divided by the total length of the sequence. * * @param sequence * a protein sequence consisting of non-ambiguous characters only * @return the composition of the 20 standard amino acid in the sequence */ public static final Map<String, Double> getAACompositionString(String sequence){ Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence); Map<String, Double> aaString2Composition = new HashMap<String, Double>(); for(AminoAcidCompound aaCompound:aa2Composition.keySet()){ aaString2Composition.put(aaCompound.getShortName(), aa2Composition.get(aaCompound)); } return aaString2Composition; }
boolean isGap = false; for(AminoAcidCompound gap : gaps) { if( aa.equals(gap)) { isGap = true; break; seq.append(aa.getShortName());
@Override public String getStringForCompound(AminoAcidCompound compound) { return compound.toString(); }
public AminoAcidCompoundSet() { aminoAcidCompoundCache.put("A", new AminoAcidCompound(this, "A", "Ala", "Alanine", 71.0788f)); aminoAcidCompoundCache.put("R", new AminoAcidCompound(this, "R", "Arg", "Arginine", 156.1875f)); aminoAcidCompoundCache.put("N", new AminoAcidCompound(this, "N", "Asn", "Asparagine", 114.1039f)); aminoAcidCompoundCache.put("D", new AminoAcidCompound(this, "D", "Asp", "Aspartic acid", 115.0886f)); aminoAcidCompoundCache.put("C", new AminoAcidCompound(this, "C", "Cys", "Cysteine", 103.1388f)); aminoAcidCompoundCache.put("E", new AminoAcidCompound(this, "E", "Glu", "Glutamic acid", 129.1155f)); aminoAcidCompoundCache.put("Q", new AminoAcidCompound(this, "Q", "Gln", "Glutamine", 128.1307f)); aminoAcidCompoundCache.put("G", new AminoAcidCompound(this, "G", "Gly", "Glycine", 57.0519f)); aminoAcidCompoundCache.put("H", new AminoAcidCompound(this, "H", "His", "Histidine", 137.1411f)); aminoAcidCompoundCache.put("I", new AminoAcidCompound(this, "I", "Ile", "Isoleucine", 113.1594f)); aminoAcidCompoundCache.put("L", new AminoAcidCompound(this, "L", "Leu", "Leucine", 113.1594f)); aminoAcidCompoundCache.put("K", new AminoAcidCompound(this, "K", "Lys", "Lysine", 128.1741f)); aminoAcidCompoundCache.put("M", new AminoAcidCompound(this, "M", "Met", "Methionine", 131.1986f)); aminoAcidCompoundCache.put("F", new AminoAcidCompound(this, "F", "Phe", "Phenylalanine", 147.1766f)); aminoAcidCompoundCache.put("P", new AminoAcidCompound(this, "P", "Pro", "Proline", 97.1167f)); aminoAcidCompoundCache.put("S", new AminoAcidCompound(this, "S", "Ser", "Serine", 87.0782f)); aminoAcidCompoundCache.put("T", new AminoAcidCompound(this, "T", "Thr", "Threonine", 101.1051f)); aminoAcidCompoundCache.put("W", new AminoAcidCompound(this, "W", "Trp", "Tryptophan", 186.2132f)); aminoAcidCompoundCache.put("Y", new AminoAcidCompound(this, "Y", "Tyr", "Tyrosine", 163.1760f)); aminoAcidCompoundCache.put("V", new AminoAcidCompound(this, "V", "Val", "Valine", 99.1326f)); aminoAcidCompoundCache.put("B", new AminoAcidCompound(this, "B", "Asx", "Asparagine or Aspartic acid", null)); aminoAcidCompoundCache.put("Z", new AminoAcidCompound(this, "Z", "Glx", "Glutamine or Glutamic acid", null)); aminoAcidCompoundCache.put("J", new AminoAcidCompound(this, "J", "Xle", "Leucine or Isoleucine", null)); aminoAcidCompoundCache.put("X", new AminoAcidCompound(this, "X", "Xaa", "Unspecified", null)); aminoAcidCompoundCache.put("-", new AminoAcidCompound(this, "-", "---", "Unspecified", null)); aminoAcidCompoundCache.put(".", new AminoAcidCompound(this, ".", "...", "Unspecified", null)); aminoAcidCompoundCache.put("_", new AminoAcidCompound(this, "_", "___", "Unspecified", null)); aminoAcidCompoundCache.put("*", new AminoAcidCompound(this, "*", "***", "Stop", null));
public CaseFreeAminoAcidCompoundSet() { aminoAcidCompoundCache.put("A", new AminoAcidCompound(null, "A", "Ala", "Alanine", 71.0788f)); aminoAcidCompoundCache.put("R", new AminoAcidCompound(null, "R", "Arg", "Arginine", 156.1875f)); aminoAcidCompoundCache.put("N", new AminoAcidCompound(null, "N", "Asn", "Asparagine", 114.1039f)); aminoAcidCompoundCache.put("D", new AminoAcidCompound(null, "D", "Asp", "Aspartic acid", 115.0886f)); aminoAcidCompoundCache.put("C", new AminoAcidCompound(null, "C", "Cys", "Cysteine", 103.1388f)); aminoAcidCompoundCache.put("E", new AminoAcidCompound(null, "E", "Glu", "Glutamic acid", 129.1155f)); aminoAcidCompoundCache.put("Q", new AminoAcidCompound(null, "Q", "Gln", "Glutamine", 128.1307f)); aminoAcidCompoundCache.put("G", new AminoAcidCompound(null, "G", "Gly", "Glycine", 57.0519f)); aminoAcidCompoundCache.put("H", new AminoAcidCompound(null, "H", "His", "Histidine", 137.1411f)); aminoAcidCompoundCache.put("I", new AminoAcidCompound(null, "I", "Ile", "Isoleucine", 113.1594f)); aminoAcidCompoundCache.put("L", new AminoAcidCompound(null, "L", "Leu", "Leucine", 113.1594f)); aminoAcidCompoundCache.put("K", new AminoAcidCompound(null, "K", "Lys", "Lysine", 128.1741f)); aminoAcidCompoundCache.put("M", new AminoAcidCompound(null, "M", "Met", "Methionine", 131.1986f)); aminoAcidCompoundCache.put("F", new AminoAcidCompound(null, "F", "Phe", "Phenylalanine", 147.1766f)); aminoAcidCompoundCache.put("P", new AminoAcidCompound(null, "P", "Pro", "Proline", 97.1167f)); aminoAcidCompoundCache.put("S", new AminoAcidCompound(null, "S", "Ser", "Serine", 87.0782f)); aminoAcidCompoundCache.put("T", new AminoAcidCompound(null, "T", "Thr", "Threonine", 101.1051f)); aminoAcidCompoundCache.put("W", new AminoAcidCompound(null, "W", "Trp", "Tryptophan", 186.2132f)); aminoAcidCompoundCache.put("Y", new AminoAcidCompound(null, "Y", "Tyr", "Tyrosine", 163.1760f)); aminoAcidCompoundCache.put("V", new AminoAcidCompound(null, "V", "Val", "Valine", 99.1326f)); aminoAcidCompoundCache.put("B", new AminoAcidCompound(null, "B", "Asx", "Asparagine or Aspartic acid", null)); aminoAcidCompoundCache.put("Z", new AminoAcidCompound(null, "Z", "Glx", "Glutamine or Glutamic acid", null)); aminoAcidCompoundCache.put("J", new AminoAcidCompound(null, "J", "Xle", "Leucine or Isoleucine", null)); aminoAcidCompoundCache.put("X", new AminoAcidCompound(null, "X", "Xaa", "Unspecified", null)); aminoAcidCompoundCache.put("-", new AminoAcidCompound(null, "-", "---", "Unspecified", null)); aminoAcidCompoundCache.put(".", new AminoAcidCompound(null, ".", "...", "Unspecified", null)); aminoAcidCompoundCache.put("_", new AminoAcidCompound(null, "_", "___", "Unspecified", null)); aminoAcidCompoundCache.put("*", new AminoAcidCompound(null, "*", "***", "Stop", null));
/** * Returns true if the given compound was a start codon in this * codon table. This will report true if the compound could ever have * been a start codon. * * @throws IllegalStateException Thrown if * {@link #getCodons(CompoundSet, CompoundSet)} was not called first. */ @Override public boolean isStart(AminoAcidCompound compound) throws IllegalStateException { if(this.codons.isEmpty()) { throw new IllegalStateException("Codons are empty; please request getCodons() fist before asking this"); } for(Codon codon: codons) { //Only check if the codon was a start codon and then ask if the compound was encoded by it if(codon.isStart()) { if(codon.getAminoAcid().equalsIgnoreCase(compound)) { return true; } } } return false; }
/** * Provided only for convenience. * * @see #fastaToAfpChain(ProteinSequence, ProteinSequence, Structure, Structure) * @throws StructureException */ public static AFPChain fastaToAfpChain(SequencePair<Sequence<AminoAcidCompound>, AminoAcidCompound> alignment, Structure structure1, Structure structure2) throws StructureException { List<AlignedSequence<Sequence<AminoAcidCompound>, AminoAcidCompound>> seqs = alignment.getAlignedSequences(); StringBuilder sb1 = new StringBuilder(); for (AminoAcidCompound a : seqs.get(0)) { sb1.append(a.getBase()); } try { ProteinSequence seq1 = new ProteinSequence(sb1.toString()); StringBuilder sb2 = new StringBuilder(); for (AminoAcidCompound a : seqs.get(1)) { sb1.append(a.getBase()); } ProteinSequence seq2 = new ProteinSequence(sb2.toString()); LinkedHashMap<String, ProteinSequence> map = new LinkedHashMap<String, ProteinSequence>(); map.put(structure1.getName(), seq1); map.put(structure2.getName(), seq2); return fastaToAfpChain(map, structure1, structure2); } catch (CompoundNotFoundException e) { logger.error("Unexpected error while creating protein sequences: {}. This is most likely a bug.",e.getMessage()); return null; } }
/** * An adaptor method to return the composition of the 20 standard amino acid in the sequence. * The sequence argument must be a protein sequence consisting of only * non-ambiguous characters. * The composition of an amino acid is the total number of its occurrence, * divided by the total length of the sequence. * * @param sequence * a protein sequence consisting of non-ambiguous characters only * @return the composition of the 20 standard amino acid in the sequence */ public static final Map<Character, Double> getAACompositionChar(String sequence){ Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence); Map<Character, Double> aaChar2Composition = new HashMap<Character, Double>(); for(AminoAcidCompound aaCompound:aa2Composition.keySet()){ aaChar2Composition.put(aaCompound.getShortName().charAt(0), aa2Composition.get(aaCompound)); } return aaChar2Composition; }
@Override public String getStringForCompound(AminoAcidCompound compound) { return compound.toString(); }
public AminoAcidCompoundSet() { aminoAcidCompoundCache.put("A", new AminoAcidCompound(this, "A", "Ala", "Alanine", 71.0788f)); aminoAcidCompoundCache.put("R", new AminoAcidCompound(this, "R", "Arg", "Arginine", 156.1875f)); aminoAcidCompoundCache.put("N", new AminoAcidCompound(this, "N", "Asn", "Asparagine", 114.1039f)); aminoAcidCompoundCache.put("D", new AminoAcidCompound(this, "D", "Asp", "Aspartic acid", 115.0886f)); aminoAcidCompoundCache.put("C", new AminoAcidCompound(this, "C", "Cys", "Cysteine", 103.1388f)); aminoAcidCompoundCache.put("E", new AminoAcidCompound(this, "E", "Glu", "Glutamic acid", 129.1155f)); aminoAcidCompoundCache.put("Q", new AminoAcidCompound(this, "Q", "Gln", "Glutamine", 128.1307f)); aminoAcidCompoundCache.put("G", new AminoAcidCompound(this, "G", "Gly", "Glycine", 57.0519f)); aminoAcidCompoundCache.put("H", new AminoAcidCompound(this, "H", "His", "Histidine", 137.1411f)); aminoAcidCompoundCache.put("I", new AminoAcidCompound(this, "I", "Ile", "Isoleucine", 113.1594f)); aminoAcidCompoundCache.put("L", new AminoAcidCompound(this, "L", "Leu", "Leucine", 113.1594f)); aminoAcidCompoundCache.put("K", new AminoAcidCompound(this, "K", "Lys", "Lysine", 128.1741f)); aminoAcidCompoundCache.put("M", new AminoAcidCompound(this, "M", "Met", "Methionine", 131.1986f)); aminoAcidCompoundCache.put("F", new AminoAcidCompound(this, "F", "Phe", "Phenylalanine", 147.1766f)); aminoAcidCompoundCache.put("P", new AminoAcidCompound(this, "P", "Pro", "Proline", 97.1167f)); aminoAcidCompoundCache.put("S", new AminoAcidCompound(this, "S", "Ser", "Serine", 87.0782f)); aminoAcidCompoundCache.put("T", new AminoAcidCompound(this, "T", "Thr", "Threonine", 101.1051f)); aminoAcidCompoundCache.put("W", new AminoAcidCompound(this, "W", "Trp", "Tryptophan", 186.2132f)); aminoAcidCompoundCache.put("Y", new AminoAcidCompound(this, "Y", "Tyr", "Tyrosine", 163.1760f)); aminoAcidCompoundCache.put("V", new AminoAcidCompound(this, "V", "Val", "Valine", 99.1326f)); aminoAcidCompoundCache.put("B", new AminoAcidCompound(this, "B", "Asx", "Asparagine or Aspartic acid", null)); aminoAcidCompoundCache.put("Z", new AminoAcidCompound(this, "Z", "Glx", "Glutamine or Glutamic acid", null)); aminoAcidCompoundCache.put("J", new AminoAcidCompound(this, "J", "Xle", "Leucine or Isoleucine", null)); aminoAcidCompoundCache.put("X", new AminoAcidCompound(this, "X", "Xaa", "Unspecified", null)); aminoAcidCompoundCache.put("-", new AminoAcidCompound(this, "-", "---", "Unspecified", null)); aminoAcidCompoundCache.put(".", new AminoAcidCompound(this, ".", "...", "Unspecified", null)); aminoAcidCompoundCache.put("_", new AminoAcidCompound(this, "_", "___", "Unspecified", null)); aminoAcidCompoundCache.put("*", new AminoAcidCompound(this, "*", "***", "Stop", null));
public ModifiedAminoAcidCompoundSet(List<AminoAcidComposition> aaList, Map<Character, Double> aaSymbol2MolecularWeight) { this.aminoAcidCompoundCache.put("-", new AminoAcidCompound(null, "-", "", "", 0.0f)); for (AminoAcidComposition aa : aaList) { this.aminoAcidCompoundCache.put(aa.getSymbol(), new AminoAcidCompound(null, aa.getSymbol(), aa.getShorName(), aa.getName(), aaSymbol2MolecularWeight.get(aa.getSymbol().charAt(0)).floatValue())); } }
/** * Returns true if the given compound was a start codon in this * codon table. This will report true if the compound could ever have * been a start codon. * * @throws IllegalStateException Thrown if * {@link #getCodons(CompoundSet, CompoundSet)} was not called first. */ @Override public boolean isStart(AminoAcidCompound compound) throws IllegalStateException { if(this.codons.isEmpty()) { throw new IllegalStateException("Codons are empty; please request getCodons() fist before asking this"); } for(Codon codon: codons) { //Only check if the codon was a start codon and then ask if the compound was encoded by it if(codon.isStart()) { if(codon.getAminoAcid().equalsIgnoreCase(compound)) { return true; } } } return false; }
/** Utility method to convert a BioJava ProteinSequence object to the FastaSequence * object used internally in JRonn. * * @param sequence * @return */ public static FastaSequence convertProteinSequencetoFasta(ProteinSequence sequence){ StringBuffer buf = new StringBuffer(); for (AminoAcidCompound compound : sequence) { String c = compound.getShortName(); if (! SequenceUtil.NON_AA.matcher(c).find()) { buf.append(c); } else { buf.append("X"); } } return new FastaSequence(sequence.getAccession().getID(),buf.toString()); }
@Override public boolean equalsIgnoreCase(Compound compound) { if (compound == null) { return false; } if (!(compound instanceof AminoAcidCompound)) { return false; } AminoAcidCompound them = (AminoAcidCompound) compound; if (toString().equalsIgnoreCase(them.toString())) { return true; } return getLongName().equalsIgnoreCase(them.getLongName()); }
public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName, String longName, String description, Float molecularWeight) { super(shortName); setShortName(shortName); setLongName(longName); setDescription(description); setMolecularWeight(molecularWeight); this.compoundSet = compoundSet; }
@Override public String getStringForCompound(AminoAcidCompound compound) { return compound.toString(); }
@Override public double getEnrichment(ProteinSequence sequence, AminoAcidCompound aminoAcidCode) { double counter = 0.0; char[] seq = this.getSequence(sequence.getSequenceAsString(), true); for(char aa:seq){ if(aminoAcidCode.getShortName().equals(String.valueOf(aa))){ counter++; } } return counter/sequence.getLength(); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof AminoAcidCompound)) { return false; } AminoAcidCompound them = (AminoAcidCompound) obj; if (toString().equals(them.toString())) { return true; } return getLongName().equals(them.getLongName()); }