Skip to content

Commit ee24288

Browse files
committed
Merge branch 'master' of https://github.com/biojava/biojava.git
2 parents ad4f4d9 + 79def6d commit ee24288

File tree

13 files changed

+587
-164
lines changed

13 files changed

+587
-164
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package org.biojava.nbio.aaproperties;
2+
3+
import java.util.Set;
4+
import java.util.stream.Collectors;
5+
import java.util.stream.Stream;
6+
7+
/**
8+
* This class provides the protein properties at the level of individual amino acids.
9+
*
10+
* @author Yana Valasatava
11+
*/
12+
public class AminoAcidProperties {
13+
14+
private static final Set<String> negChargedAAs = Stream.of("D", "E").collect(Collectors.toSet());
15+
private static final Set<String> posChargedAAs = Stream.of("K", "R", "H").collect(Collectors.toSet());
16+
private static final Set<String> polarAAs = Stream.of("D", "E", "K", "R", "H", "N", "Q", "S", "T", "Y")
17+
.collect(Collectors.toSet());
18+
19+
/**
20+
* At pH=7, two are negative charged: aspartic acid (Asp, D) and glutamic acid (Glu, E) (acidic side chains),
21+
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
22+
*
23+
* @param aa The one-letter amino acid code
24+
* @return true if amino acid is charged
25+
*/
26+
public static final boolean isCharged(char aa) {
27+
if (negChargedAAs.contains(String.valueOf(aa))) {
28+
return true;
29+
}
30+
else if (posChargedAAs.contains(String.valueOf(aa))) {
31+
return true;
32+
}
33+
return false;
34+
}
35+
36+
/**
37+
* Returns the charge of amino acid. At pH=7, two are negative charged: aspartic acid (Asp, D) and glutamic acid (Glu, E) (acidic side chains),
38+
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
39+
*
40+
* @param aa The one-letter amino acid code
41+
* @return the charge of amino acid (1 if positively charged, -1 if negatively charged, 0 if not charged)
42+
*/
43+
public static final int getChargeOfAminoAcid(char aa) {
44+
if (negChargedAAs.contains(String.valueOf(aa))) {
45+
return -1;
46+
}
47+
else if (posChargedAAs.contains(String.valueOf(aa))) {
48+
return 1;
49+
}
50+
return 0;
51+
}
52+
53+
/**
54+
* There are 10 amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
55+
*
56+
* @param aa The one-letter amino acid code
57+
* @return true if amino acid is polar
58+
*/
59+
public static final boolean isPolar(char aa) {
60+
if (polarAAs.contains(String.valueOf(aa))) {
61+
return true;
62+
}
63+
return false;
64+
}
65+
66+
/**
67+
* There are 10 amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
68+
*
69+
* @param aa The one-letter amino acid code
70+
* @return the polarity of amino acid (1 if polar, 0 if not polar)
71+
*/
72+
public static final int getPolarityOfAminoAcid(char aa) {
73+
if (polarAAs.contains(String.valueOf(aa))) {
74+
return 1;
75+
}
76+
return 0;
77+
}
78+
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,4 +555,37 @@ public static final Map<Character, Double> getAACompositionChar(String sequence)
555555
}
556556
return aaChar2Composition;
557557
}
558+
559+
/**
560+
* Returns the array of charges of each amino acid in a protein. At pH=7, two are negative charged: aspartic acid (Asp, D) and glutamic acid (Glu, E) (acidic side chains),
561+
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
562+
*
563+
* @param sequence
564+
* a protein sequence consisting of non-ambiguous characters only
565+
* @return the array of charges of amino acids in the protein (1 if amino acid is positively charged, -1 if negatively charged, 0 if not charged)
566+
*/
567+
public static final int[] getChargesOfAminoAcids(String sequence) {
568+
int[] charges = new int[sequence.length()];
569+
for ( int i=0; i < sequence.length(); i++ ) {
570+
char aa = sequence.toCharArray()[i];
571+
charges[i] = AminoAcidProperties.getChargeOfAminoAcid(aa);
572+
}
573+
return charges;
574+
}
575+
576+
/**
577+
* Returns the array of polarity values of each amino acid in a protein sequence.
578+
*
579+
* @param sequence
580+
* a protein sequence consisting of non-ambiguous characters only
581+
* @return the array of polarity of amino acids in the protein (1 if amino acid is polar, 0 if not)
582+
*/
583+
public static final int[] getPolarityOfAminoAcids(String sequence) {
584+
int[] polarity = new int[sequence.length()];
585+
for ( int i=0; i < sequence.length(); i++ ) {
586+
char aa = sequence.toCharArray()[i];
587+
polarity[i] = AminoAcidProperties.getPolarityOfAminoAcid(aa);
588+
}
589+
return polarity;
590+
}
558591
}

0 commit comments

Comments
 (0)