/** * 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; }
/** * 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; }
/** 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 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(); }
seq.append(aa.getShortName());