Skip to content

Commit 4c7dc72

Browse files
author
Yana Valasatava
committed
Serializable Jronn
1 parent ef3b83a commit 4c7dc72

4 files changed

Lines changed: 126 additions & 3 deletions

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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", "K", "R", "H").collect(Collectors.toSet());
15+
private static final Set<String> posChargedAAs = Stream.of("D", "E", "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+
*
25+
* @return true if amino acid is charged
26+
*/
27+
public static final boolean isCharged(char aa) {
28+
if (negChargedAAs.contains(aa)) {
29+
return true;
30+
}
31+
else if (posChargedAAs.contains(aa)) {
32+
return true;
33+
}
34+
return false;
35+
}
36+
37+
/**
38+
* 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),
39+
* and three are positive charged: lysine (Lys, K), arginine (Arg, R) and histidine (His, H) (basic side chains).
40+
*
41+
* @param aa The one-letter amino acid code
42+
*
43+
* @return the charge of amino acid (1 if positively charged, -1 if negatively charged, 0 if not charged)
44+
*/
45+
public static final int getChargeOfAminoAcid(char aa) {
46+
if (negChargedAAs.contains(aa)) {
47+
return -1;
48+
}
49+
else if (posChargedAAs.contains(aa)) {
50+
return 1;
51+
}
52+
return 0;
53+
}
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+
}
73+
74+
/**
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
78+
*
79+
* @return true if amino acid is polar
80+
*/
81+
public static final boolean isPolar(char aa) {
82+
if (polarAAs.contains(aa)) {
83+
return true;
84+
}
85+
return false;
86+
}
87+
88+
/**
89+
* There are 10 polar amino acids: D, E, H, K, R, N, Q, S, T, Y, that are polar.
90+
*
91+
* @param aa The one-letter amino acid code
92+
*
93+
* @return the polarity of amino acid (1 if polar, 0 if not polar)
94+
*/
95+
public static final int getPolarityOfAminoAcid(char aa) {
96+
if (polarAAs.contains(aa)) {
97+
return 1;
98+
}
99+
return 0;
100+
}
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+
}

biojava-protein-disorder/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>biojava</artifactId>
55
<groupId>org.biojava</groupId>
6-
<version>5.0.0-SNAPSHOT</version>
6+
<version>5.0.0-YV-SNAPSHOT</version>
77
</parent>
88
<artifactId>biojava-protein-disorder</artifactId>
99
<packaging>jar</packaging>

biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.FileInputStream;
2828
import java.io.FileNotFoundException;
2929
import java.io.IOException;
30+
import java.io.Serializable;
3031
import java.util.ArrayList;
3132
import java.util.List;
3233
import java.util.Map;
@@ -46,8 +47,12 @@
4647
* @since 3.0.2
4748
*
4849
*/
49-
public class Jronn {
50+
public class Jronn implements Serializable {
5051

52+
/**
53+
*
54+
*/
55+
private static final long serialVersionUID = 8104272449130849946L;
5156
// Load models
5257
private static final ModelLoader loader = new ModelLoader();
5358
static {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<groupId>org.biojava</groupId>
1313
<artifactId>biojava</artifactId>
1414
<packaging>pom</packaging>
15-
<version>5.0.0-SNAPSHOT</version>
15+
<version>5.0.0-YV-SNAPSHOT</version>
1616
<name>biojava</name>
1717
<description>BioJava is an open-source project dedicated to providing a Java framework for processing biological
1818
data. It provides analytical and statistical routines, parsers for common file formats and allows the

0 commit comments

Comments
 (0)