@Override public double getAvgHydropathy(ProteinSequence sequence) { int validLength = 0; double total = 0.0; AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); char[] seq = this.getSequence(sequence.toString(), true); for(char aa:seq){ AminoAcidCompound c = aaSet.getCompoundForString(String.valueOf(aa)); if(Constraints.aa2Hydrophathicity.containsKey(c)){ total += Constraints.aa2Hydrophathicity.get(c); validLength++; } } if (validLength==0) { logger.warn("Valid length of sequence is 0, can't divide by 0 to calculate average hydropathy: setting average hydropathy to 0"); return 0.0; } return total / validLength; }
@Override public double getMolecularWeight(ProteinSequence sequence) { double value = 0.0; AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); char[] seq = getSequence(sequence.toString(), true);//ignore case for(char aa:seq){ AminoAcidCompound c = aaSet.getCompoundForString(String.valueOf(aa)); if(Constraints.aa2MolecularWeight.containsKey(c)){ value += Constraints.aa2MolecularWeight.get(c); } } if(value == 0) return value; else return value + getWaterMoleculeWeight(); }
private Map<AminoAcidCompound, Integer> getExtinctAACount(ProteinSequence sequence){ //Cys => C, Tyr => Y, Trp => W int numW = 0; int smallW = 0; double numC = 0; double smallC = 0; int numY = 0; int smallY = 0; for(char aa:sequence.getSequenceAsString().toCharArray()){ switch(aa){ case 'W': numW++; break; case 'w': smallW++; break; case 'C': numC += 0.5; break; case 'c': smallC += 0.5; break; case 'Y': numY++; break; case 'y': smallY++; break; } } AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<AminoAcidCompound, Integer>(); //Ignore Case is always true extinctAA2Count.put(aaSet.getCompoundForString("W"), numW + smallW); extinctAA2Count.put(aaSet.getCompoundForString("C"), (int) (numC + smallC)); extinctAA2Count.put(aaSet.getCompoundForString("Y"), numY + smallY); return extinctAA2Count; }
@Override public double getApliphaticIndex(ProteinSequence sequence) { // Aliphatic index = X(Ala) + a * X(Val) + b * ( X(Ile) + X(Leu) ) // where X(Ala), X(Val), X(Ile), and X(Leu) are mole percent (100 X mole fraction) // of alanine, valine, isoleucine, and leucine. // The coefficients a and b are the relative volume of valine side chain (a = 2.9) // and of Leu/Ile side chains (b = 3.9) to the side chain of alanine. // Ala => A, Val => V, Ile => I, Leu => L AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence); final double a = 2.9; final double b = 3.9; double xAla = aa2Composition.get(aaSet.getCompoundForString("A")); double xVal = aa2Composition.get(aaSet.getCompoundForString("V")); double xIle = aa2Composition.get(aaSet.getCompoundForString("I")); double xLeu = aa2Composition.get(aaSet.getCompoundForString("L")); return (xAla + (a * xVal) + (b * (xIle + xLeu))) * 100; }
@Override public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence) { int validLength = 0; Map<AminoAcidCompound, Double> aa2Composition = new HashMap<AminoAcidCompound, Double>(); AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); for(AminoAcidCompound aa:aaSet.getAllCompounds()){ aa2Composition.put(aa, 0.0); } char[] seq = this.getSequence(sequence.toString(), true); for(char aa:seq){ if(PeptideProperties.standardAASet.contains(aa)){ AminoAcidCompound compound = aaSet.getCompoundForString(String.valueOf(aa)); aa2Composition.put(compound, aa2Composition.get(compound) + 1.0); validLength++; } } if(validLength > 0){ for(AminoAcidCompound aa:aaSet.getAllCompounds()){ aa2Composition.put(aa, aa2Composition.get(aa) / validLength); } }else{ for(AminoAcidCompound aa:aaSet.getAllCompounds()){ aa2Composition.put(aa, 0.0); } } return aa2Composition; } }
@Override public double getExtinctionCoefficient(ProteinSequence sequence, boolean assumeCysReduced) { //Tyr => Y //Trp => W //Cys => C //E(Prot) = Numb(Tyr)*Ext(Tyr) + Numb(Trp)*Ext(Trp) + Numb(Cystine)*Ext(Cystine) //where (for proteins in water measured at 280 nm): Ext(Tyr) = 1490, Ext(Trp) = 5500, Ext(Cystine) = 125; AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); Map<AminoAcidCompound, Integer> extinctAA2Count = this.getExtinctAACount(sequence); double eProt; if(!assumeCysReduced){ eProt = extinctAA2Count.get(aaSet.getCompoundForString("Y")) * Constraints.aa2ExtinctionCoefficient.get(aaSet.getCompoundForString("Y")) + extinctAA2Count.get(aaSet.getCompoundForString("W")) * Constraints.aa2ExtinctionCoefficient.get(aaSet.getCompoundForString("W")) + extinctAA2Count.get(aaSet.getCompoundForString("C")) * Constraints.aa2ExtinctionCoefficient.get(aaSet.getCompoundForString("C")); }else eProt = extinctAA2Count.get(aaSet.getCompoundForString("Y")) * Constraints.aa2ExtinctionCoefficient.get(aaSet.getCompoundForString("Y")) + extinctAA2Count.get(aaSet.getCompoundForString("W")) * Constraints.aa2ExtinctionCoefficient.get(aaSet.getCompoundForString("W")); return eProt; }
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); Map<AminoAcidCompound, Integer> chargedAA2Count = new HashMap<AminoAcidCompound, Integer>(); chargedAA2Count.put(aaSet.getCompoundForString("K"), numK);
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
/** * An adaptor method to return the composition of specified amino acid in the sequence. The * sequence argument must be a protein sequence consisting of only * non-ambiguous characters. The aminoAcidCode must be a non-ambiguous * character. * 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 * @param aminoAcidCode * the code of the amino acid to compute * @return the composition of specified amino acid in the sequence */ public static final double getEnrichment(String sequence, String aminoAcidCode){ sequence = Utils.checkSequence(sequence); ProteinSequence pSequence = null; try { pSequence = new ProteinSequence(sequence); } catch (CompoundNotFoundException e) { // the sequence was checked with Utils.checkSequence, this shouldn't happen logger.error("The protein sequence contains invalid characters ({}), this should not happen. This is most likely a bug in Utils.checkSequence()", e.getMessage()); } IPeptideProperties pp = new PeptidePropertiesImpl(); AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet(); return pp.getEnrichment(pSequence, aaSet.getCompoundForString(aminoAcidCode)); }