@@ -72,7 +72,7 @@ public class BasePairParameters implements Serializable {
7272 // See URL http://ndbserver.rutgers.edu/ndbmodule/archives/reports/tsukuba/Table1.html
7373 // and the paper cited at the top of this class (also as Table 1).
7474 // These are hard-coded to avoid problems with resource paths.
75- public static String [] standardBases = new String [] {
75+ public static final String [] STANDARD_BASES = new String [] {
7676 "SEQRES 1 A 1 A\n " +
7777 "ATOM 2 N9 A A 1 -1.291 4.498 0.000\n " +
7878 "ATOM 3 C8 A A 1 0.024 4.897 0.000\n " +
@@ -121,24 +121,24 @@ public class BasePairParameters implements Serializable {
121121 };
122122
123123 // this is also hard-coded data about standard WC base pairs for both DNA and RNA
124- protected static String [] baseListDNA = {"A" , "G" , "T" , "C" };
125- protected static String [] baseListRNA = {"A" , "G" , "U" , "C" };
126- protected static Map <String , Integer > map ;
124+ protected static final String [] BASE_LIST_DNA = {"A" , "G" , "T" , "C" };
125+ protected static final String [] BASE_LIST_RNA = {"A" , "G" , "U" , "C" };
126+ protected static final Map <String , Integer > BASE_MAP ;
127127 // private static List<String> RNAspecific = Arrays.asList("U", "URA"),
128128 // DNAspecific = Arrays.asList("DC", "C", "CYT");
129- protected static Map <Integer , List <String >> ringMap ;
129+ protected static final Map <Integer , List <String >> RING_MAP ;
130130 static {
131- map = new HashMap <>();
132- map .put ("DA" , 0 ); map .put ("ADE" , 0 ); map .put ("A" , 0 );
133- map .put ("DG" , 1 ); map .put ("GUA" , 1 ); map .put ("G" , 1 );
134- map .put ("DT" , 2 ); map .put ("THY" , 2 ); map .put ("T" , 2 ); map .put ("U" , 2 ); map .put ("URA" , 2 );
135- map .put ("DC" , 3 ); map .put ("CYT" , 3 ); map .put ("C" , 3 );
136-
137- ringMap = new HashMap <>();
138- ringMap .put (0 , Arrays .asList ("C8" , "C2" , "N3" , "C4" , "C5" , "C6" , "N7" , "N1" , "N9" ));
139- ringMap .put (1 , Arrays .asList ("C8" , "C2" , "N3" , "C4" , "C5" , "C6" , "N7" , "N1" , "N9" ));
140- ringMap .put (2 , Arrays .asList ("C6" , "C2" , "N3" , "C4" , "C5" , "N1" ));
141- ringMap .put (3 , Arrays .asList ("C6" , "C2" , "N3" , "C4" , "C5" , "N1" ));
131+ BASE_MAP = new HashMap <>();
132+ BASE_MAP .put ("DA" , 0 ); BASE_MAP .put ("ADE" , 0 ); BASE_MAP .put ("A" , 0 );
133+ BASE_MAP .put ("DG" , 1 ); BASE_MAP .put ("GUA" , 1 ); BASE_MAP .put ("G" , 1 );
134+ BASE_MAP .put ("DT" , 2 ); BASE_MAP .put ("THY" , 2 ); BASE_MAP .put ("T" , 2 ); BASE_MAP .put ("U" , 2 ); BASE_MAP .put ("URA" , 2 );
135+ BASE_MAP .put ("DC" , 3 ); BASE_MAP .put ("CYT" , 3 ); BASE_MAP .put ("C" , 3 );
136+
137+ RING_MAP = new HashMap <>();
138+ RING_MAP .put (0 , Arrays .asList ("C8" , "C2" , "N3" , "C4" , "C5" , "C6" , "N7" , "N1" , "N9" ));
139+ RING_MAP .put (1 , Arrays .asList ("C8" , "C2" , "N3" , "C4" , "C5" , "C6" , "N7" , "N1" , "N9" ));
140+ RING_MAP .put (2 , Arrays .asList ("C6" , "C2" , "N3" , "C4" , "C5" , "N1" ));
141+ RING_MAP .put (3 , Arrays .asList ("C6" , "C2" , "N3" , "C4" , "C5" , "N1" ));
142142 }
143143
144144 protected transient Structure structure ;
@@ -172,10 +172,22 @@ public BasePairParameters(Structure structure, boolean useRNA, boolean removeDup
172172
173173 }
174174
175+ /**
176+ * Constructor takes a Structure object, whether to use RNA, and whether to remove duplicate sequences.
177+ * @param structure The already-loaded structure to analyze.
178+ * @param useRNA if true, the RNA standard bases will be used. Otherwise, if false, it will work on standard DNA bases.
179+ * @param removeDups if true, duplicate sequences will not be considered. This is for the analysis of X-ray structures from
180+ * RCSB, where there may be identical or similar units.
181+ */
175182 public BasePairParameters (Structure structure , boolean useRNA , boolean removeDups ) {
176183 this (structure , useRNA , removeDups , false );
177184 }
178185
186+ /**
187+ * Constructor takes a Structure object, and whether to use the RNA standard bases
188+ * @param structure The already-loaded structure to analyze.
189+ * @param useRNA if true, the RNA standard bases will be used. Otherwise, if false, it will work on standard DNA bases.
190+ */
179191 public BasePairParameters (Structure structure , boolean useRNA ) {
180192 this (structure , useRNA , false , false );
181193 }
@@ -449,14 +461,14 @@ public List<Pair<Group>> findPairs(List<Chain> chains) {
449461 for (int k = 0 ; k < match .length (); k ++) {
450462 Group g1 = c .getAtomGroup (index1 +k );
451463 Group g2 = chains .get (j ).getAtomGroup (index2 -k );
452- Integer type1 = map .get (g1 .getPDBName ());
453- Integer type2 = map .get (g2 .getPDBName ());
464+ Integer type1 = BASE_MAP .get (g1 .getPDBName ());
465+ Integer type2 = BASE_MAP .get (g2 .getPDBName ());
454466 if (type1 == null || type2 == null ) {
455467 if (pairSequence .length () != 0 && pairSequence .charAt (pairSequence .length ()-1 ) != ' ' ) pairSequence += ' ' ;
456468 continue ;
457469 }
458- Atom a1 = g1 .getAtom (ringMap .get (type1 ).get (0 ));
459- Atom a2 = g2 .getAtom (ringMap .get (type2 ).get (0 ));
470+ Atom a1 = g1 .getAtom (RING_MAP .get (type1 ).get (0 ));
471+ Atom a2 = g2 .getAtom (RING_MAP .get (type2 ).get (0 ));
460472
461473 if (a1 == null ) {
462474 log .info ("Error processing " + g1 .getPDBName ());
@@ -477,17 +489,17 @@ public List<Pair<Group>> findPairs(List<Chain> chains) {
477489 // could be a base pair
478490 if (Math .abs (distance -10.0 ) < 4.0 ) {
479491 boolean valid = true ;
480- for (String atomname : ringMap .get (type1 )) {
492+ for (String atomname : RING_MAP .get (type1 )) {
481493 Atom a = g1 .getAtom (atomname );
482494 if (a == null ) valid = false ;
483495 }
484- if (valid ) for (String atomname : ringMap .get (type2 )) {
496+ if (valid ) for (String atomname : RING_MAP .get (type2 )) {
485497 Atom a = g2 .getAtom (atomname );
486498 if (a == null ) valid = false ;
487499 }
488500 if (valid ) {
489501 result .add (new Pair <Group >(g1 , g2 ));
490- pairingNames .add ((useRNA ? baseListRNA [type1 ]+baseListRNA [type2 ] : baseListDNA [type1 ]+baseListDNA [type2 ]));
502+ pairingNames .add ((useRNA ? BASE_LIST_RNA [type1 ]+ BASE_LIST_RNA [type2 ] : BASE_LIST_DNA [type1 ]+ BASE_LIST_DNA [type2 ]));
491503 pairSequence += c .getAtomSequence ().charAt (index1 + k );
492504 } else if (pairSequence .length () != 0 && pairSequence .charAt (pairSequence .length ()-1 ) != ' ' ) pairSequence += ' ' ;
493505 } else if (pairSequence .length () != 0 && pairSequence .charAt (pairSequence .length ()-1 ) != ' ' ) pairSequence += ' ' ;
@@ -507,15 +519,15 @@ public List<Pair<Group>> findPairs(List<Chain> chains) {
507519 * @return The middle frame of the center of the base-pair formed
508520 */
509521 public Matrix4d basePairReferenceFrame (Pair <Group > pair ) {
510- Integer type1 = map .get (pair .getFirst ().getPDBName ());
511- Integer type2 = map .get (pair .getSecond ().getPDBName ());
522+ Integer type1 = BASE_MAP .get (pair .getFirst ().getPDBName ());
523+ Integer type2 = BASE_MAP .get (pair .getSecond ().getPDBName ());
512524 SuperPosition sp = new SuperPositionQCP (true );
513525 if (type1 == null || type2 == null ) return null ;
514526 PDBFileReader pdbFileReader = new PDBFileReader ();
515527 Structure s1 , s2 ;
516528 try {
517- s1 = pdbFileReader .getStructure (new ByteArrayInputStream (standardBases [type1 ].getBytes ()));
518- s2 = pdbFileReader .getStructure (new ByteArrayInputStream (standardBases [type2 ].getBytes ()));
529+ s1 = pdbFileReader .getStructure (new ByteArrayInputStream (STANDARD_BASES [type1 ].getBytes ()));
530+ s2 = pdbFileReader .getStructure (new ByteArrayInputStream (STANDARD_BASES [type2 ].getBytes ()));
519531 } catch (IOException e ) {
520532 e .printStackTrace ();
521533 return null ;
0 commit comments