Skip to content

Commit d3a0648

Browse files
author
Yana Valasatava
committed
Moving the code responsible for the properties at the protein sequence level to the PeptideProperties class
1 parent e5f76ec commit d3a0648

File tree

2 files changed

+38
-51
lines changed

2 files changed

+38
-51
lines changed

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

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class AminoAcidProperties {
2020
* At pH=7, two are negative charged: aspartic acid (Asp, D) and glutamic acid (Glu, E) (acidic side chains),
2121
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
2222
*
23-
* @param aa The one-letter amino acid code
24-
*
23+
* @param aa The one-letter amino acid code
2524
* @return true if amino acid is charged
2625
*/
2726
public static final boolean isCharged(char aa) {
@@ -38,8 +37,7 @@ else if (posChargedAAs.contains(String.valueOf(aa))) {
3837
* 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),
3938
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
4039
*
41-
* @param aa The one-letter amino acid code
42-
*
40+
* @param aa The one-letter amino acid code
4341
* @return the charge of amino acid (1 if positively charged, -1 if negatively charged, 0 if not charged)
4442
*/
4543
public static final int getChargeOfAminoAcid(char aa) {
@@ -51,31 +49,11 @@ else if (posChargedAAs.contains(String.valueOf(aa))) {
5149
}
5250
return 0;
5351
}
54-
55-
/**
56-
* 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),
57-
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
58-
*
59-
* @param aa The one-letter amino acid code
60-
*
61-
* @return the array of charges of amino acids in the protein (1 if amino acid is positively charged,
62-
* -1 if negatively charged, 0 if not charged)
63-
*/
64-
public static final int[] getChargesOfAminoAcidsInProtein(String protein) {
65-
66-
int[] charges = new int[protein.length()];
67-
for ( int i=0; i < protein.length(); i++ ) {
68-
char aa = protein.toCharArray()[i];
69-
charges[i] = getChargeOfAminoAcid(aa);
70-
}
71-
return charges;
72-
}
7352

7453
/**
75-
* There are 10 polar amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
76-
*
77-
* @param aa The one-letter amino acid code
54+
* There are 10 amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
7855
*
56+
* @param aa The one-letter amino acid code
7957
* @return true if amino acid is polar
8058
*/
8159
public static final boolean isPolar(char aa) {
@@ -86,10 +64,9 @@ public static final boolean isPolar(char aa) {
8664
}
8765

8866
/**
89-
* There are 10 polar amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
67+
* There are 10 amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
9068
*
9169
* @param aa The one-letter amino acid code
92-
*
9370
* @return the polarity of amino acid (1 if polar, 0 if not polar)
9471
*/
9572
public static final int getPolarityOfAminoAcid(char aa) {
@@ -98,27 +75,4 @@ public static final int getPolarityOfAminoAcid(char aa) {
9875
}
9976
return 0;
10077
}
101-
102-
/**
103-
* Returns the array of polarity of each amino acid in a protein.
104-
*
105-
* @param aa The one-letter amino acid code
106-
*
107-
* @return the array of polarity of amino acids in the protein (1 if amino acid is polar, 0 if not)
108-
*/
109-
public static final int[] getPolarityOfAminoAcidsInProtein(String protein) {
110-
111-
int[] polarity = new int[protein.length()];
112-
for ( int i=0; i < protein.length(); i++ ) {
113-
char aa = protein.toCharArray()[i];
114-
polarity[i] = getPolarityOfAminoAcid(aa);
115-
}
116-
return polarity;
117-
}
118-
119-
public static void main(String[] args) {
120-
System.out.println(getChargeOfAminoAcid('D'));
121-
System.out.println(getChargeOfAminoAcid('K'));
122-
System.out.println(getChargeOfAminoAcid('A'));
123-
}
12478
}

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[] getChargesOfAminoAcidsInProtein(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[] getPolarityOfAminoAcidsInProtein(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)