1111 */
1212public class AminoAcidProperties {
1313
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 ());
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 ());
1616 private static final Set <String > polarAAs = Stream .of ("D" , "E" , "K" , "R" , "H" , "N" , "Q" , "S" , "T" , "Y" )
1717 .collect (Collectors .toSet ());
1818
@@ -25,10 +25,10 @@ public class AminoAcidProperties {
2525 * @return true if amino acid is charged
2626 */
2727 public static final boolean isCharged (char aa ) {
28- if (negChargedAAs .contains (aa )) {
28+ if (negChargedAAs .contains (String . valueOf ( aa ) )) {
2929 return true ;
3030 }
31- else if (posChargedAAs .contains (aa )) {
31+ else if (posChargedAAs .contains (String . valueOf ( aa ) )) {
3232 return true ;
3333 }
3434 return false ;
@@ -43,10 +43,10 @@ else if (posChargedAAs.contains(aa)) {
4343 * @return the charge of amino acid (1 if positively charged, -1 if negatively charged, 0 if not charged)
4444 */
4545 public static final int getChargeOfAminoAcid (char aa ) {
46- if (negChargedAAs .contains (aa )) {
46+ if (negChargedAAs .contains (String . valueOf ( aa ) )) {
4747 return -1 ;
4848 }
49- else if (posChargedAAs .contains (aa )) {
49+ else if (posChargedAAs .contains (String . valueOf ( aa ) )) {
5050 return 1 ;
5151 }
5252 return 0 ;
@@ -79,7 +79,7 @@ public static final int[] getChargesOfAminoAcidsInProtein(String protein) {
7979 * @return true if amino acid is polar
8080 */
8181 public static final boolean isPolar (char aa ) {
82- if (polarAAs .contains (aa )) {
82+ if (polarAAs .contains (String . valueOf ( aa ) )) {
8383 return true ;
8484 }
8585 return false ;
@@ -93,7 +93,7 @@ public static final boolean isPolar(char aa) {
9393 * @return the polarity of amino acid (1 if polar, 0 if not polar)
9494 */
9595 public static final int getPolarityOfAminoAcid (char aa ) {
96- if (polarAAs .contains (aa )) {
96+ if (polarAAs .contains (String . valueOf ( aa ) )) {
9797 return 1 ;
9898 }
9999 return 0 ;
@@ -115,4 +115,10 @@ public static final int[] getPolarityOfAminoAcidsInProtein(String protein) {
115115 }
116116 return polarity ;
117117 }
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+ }
118124}
0 commit comments