Skip to content

Commit 2834ada

Browse files
committed
Aromaticity calculation (Protein) #1037
Calculates the aromaticity value of a protein according to Lobry, 1994. It is simply the relative frequency of Phe(F)+Trp(W)+Tyr(Y).
1 parent 059fbf1 commit 2834ada

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/IPeptideProperties.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,15 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
312312
* @see AminoAcidCompound
313313
*/
314314
public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence);
315+
316+
/**
317+
* Calculates the aromaticity value of a protein according to Lobry, 1994.
318+
* It is simply the relative frequency of Phe+Trp+Tyr.
319+
*
320+
* @param sequence
321+
* a protein sequence consisting of non-ambiguous characters only
322+
* @return the aromaticity of a protein sequence
323+
* @see ProteinSequence
324+
*/
325+
public double getAromaticity(ProteinSequence sequence);
315326
}

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/PeptideProperties.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,28 @@ public static final int[] getPolarityOfAminoAcids(String sequence) {
590590
}
591591
return polarity;
592592
}
593+
594+
/**
595+
* An adaptor method to return the aromaticity value of sequence. The sequence argument
596+
* must be a protein sequence consisting of only non-ambiguous characters.
597+
*
598+
* Calculates the aromaticity value of a protein according to Lobry, 1994.
599+
* It is simply the relative frequency of Phe+Trp+Tyr.
600+
* *
601+
* @param sequence
602+
* a protein sequence consisting of non-ambiguous characters only
603+
* @return the aromaticity value of sequence
604+
*/
605+
public static final double getAromaticity(String sequence) {
606+
sequence = Utils.checkSequence(sequence);
607+
ProteinSequence pSequence = null;
608+
try {
609+
pSequence = new ProteinSequence(sequence);
610+
} catch (CompoundNotFoundException e) {
611+
// the sequence was checked with Utils.checkSequence, this shouldn't happen
612+
logger.error("The protein sequence contains invalid characters ({}), this should not happen. This is most likely a bug in Utils.checkSequence()", e.getMessage());
613+
}
614+
IPeptideProperties pp = new PeptidePropertiesImpl();
615+
return pp.getAromaticity(pSequence);
616+
}
593617
}

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/PeptidePropertiesImpl.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,4 +582,35 @@ public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence)
582582
}
583583
return aa2Composition;
584584
}
585+
586+
587+
@Override
588+
public double getAromaticity(ProteinSequence sequence) {
589+
int validLength = sequence.getSequenceAsString().length();
590+
591+
if (validLength==0) {
592+
logger.warn("Valid length of sequence is 0, can't divide by 0 to calculate aromaticity: setting aromaticity to 0");
593+
return 0.0;
594+
}
595+
596+
//Phe - Phenylalanine
597+
int totalF=0;
598+
//Tyr - Tyrosine
599+
int totalY=0;
600+
//Trp - Tryptophan
601+
int totalW=0;
602+
603+
char[] seq = this.getSequence(sequence.toString(), true);
604+
for(char aa:seq){
605+
char amino = Character.toUpperCase(aa);
606+
switch(amino){
607+
case 'F' : totalF++;break;
608+
case 'Y' : totalY++;break;
609+
case 'W' : totalW++;break;
610+
}
611+
}
612+
613+
return (totalF+totalY+totalW)/(double)(validLength);
614+
}
585615
}
616+

biojava-aa-prop/src/test/java/org/biojava/nbio/aaproperties/PeptidePropertiesImplTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,12 @@ public void testNetCharge(){
358358
public void testNetChargeNull(){
359359
assertEquals(8.6, PeptideProperties.getNetCharge(null), delta);
360360
}
361+
362+
@Test
363+
public void testAromaticity(){
364+
assertEquals(1, PeptideProperties.getAromaticity("WWWYYYYFFFWWWYYYYFFF"), 0.001);
365+
assertEquals(0.5, PeptideProperties.getAromaticity("WWWYYYYFFFAAAAAAAAAA"), 0.001);
366+
assertEquals(0.08, PeptideProperties.getAromaticity(sequence), 0.001);
367+
assertEquals(0.0, PeptideProperties.getAromaticity(fullInvalidSequence), 0.001);
368+
}
361369
}

0 commit comments

Comments
 (0)