@@ -36,7 +36,7 @@ public class BasePairParameters {
3636 // See URL http://ndbserver.rutgers.edu/ndbmodule/archives/reports/tsukuba/Table1.html
3737 // and the paper cited at the top of this class (also as Table 1).
3838 // These are hard-coded to avoid problems with resource paths.
39- private static String [] standardBases = new String [] {
39+ public static String [] standardBases = new String [] {
4040 "SEQRES 1 A 1 A\n " +
4141 "ATOM 2 N9 A A 1 -1.291 4.498 0.000\n " +
4242 "ATOM 3 C8 A A 1 0.024 4.897 0.000\n " +
@@ -110,7 +110,9 @@ public class BasePairParameters {
110110 }
111111
112112 protected Structure structure ;
113+ protected boolean canonical = true ;
113114 protected boolean useRNA = false ;
115+ protected boolean nonredundant = false ;
114116 protected double [] pairParameters ;
115117
116118 // this is the main data that you want to get back out from the procedure.
@@ -128,19 +130,50 @@ public class BasePairParameters {
128130 * @param useRNA whether to look for canonical RNA pairs. By default (false) it analyzes DNA.
129131 * @param removeDups whether to only look for base-pair parameters for each unique sequence in
130132 * the structure (if set to <i>true</i>)
133+ * @param canonical Whether to consider only Watson-Crick base pairs
131134 */
132- public BasePairParameters (Structure structure , boolean useRNA , boolean removeDups ) {
135+ public BasePairParameters (Structure structure , boolean useRNA , boolean removeDups , boolean canonical ) {
133136 this .structure = structure ;
134137 this .useRNA = useRNA ;
138+ this .canonical = canonical ;
139+ this .nonredundant = removeDups ;
140+
141+ }
142+
143+ public BasePairParameters (Structure structure , boolean useRNA , boolean removeDups ) {
144+ this (structure , useRNA , removeDups , false );
145+ }
146+
147+ public BasePairParameters (Structure structure , boolean useRNA ) {
148+ this (structure , useRNA , false , false );
149+ }
150+
151+ /**
152+ * Constructor takes a Structure object, finds base pair and base-pair step parameters
153+ * for double-helical regions within the structure for only canonical DNA pairs.
154+ * @param structure The already-loaded structure to analyze.
155+ */
156+ public BasePairParameters (Structure structure ) {
157+ this (structure , false , false , true );
158+ }
159+
160+
161+ /**
162+ * This is the main function call to extract all step parameters, pairing parameters, and sequence
163+ * information from the Structure object provided to the constructor.
164+ * @return This same object with the populated data, convenient for output
165+ * (e.g. <i>log.info(new BasePairParameters(structure).analyze());</i>)
166+ */
167+ public BasePairParameters analyze () {
135168 if (structure == null ) {
136169 pairingParameters = null ;
137170 stepParameters = null ;
138- return ;
171+ return this ;
139172 }
140- List <Chain > nucleics = this .getNucleicChains (removeDups );
173+ List <Chain > nucleics = this .getNucleicChains (nonredundant );
141174 List <Group []> pairs = this .findPairs (nucleics );
142- pairingParameters = new double [pairs .size ()][6 ];
143- stepParameters = new double [pairs .size ()][6 ];
175+ this . pairingParameters = new double [pairs .size ()][6 ];
176+ this . stepParameters = new double [pairs .size ()][6 ];
144177 Matrix4d lastStep ;
145178 Matrix4d currentStep = null ;
146179 for (int i = 0 ; i < pairs .size (); i ++) {
@@ -154,20 +187,11 @@ public BasePairParameters(Structure structure, boolean useRNA, boolean removeDup
154187 double [] sparms = calculatetp (lastStep );
155188 for (int j = 0 ; j < 6 ; j ++) stepParameters [i ][j ] = sparms [j ];
156189 }
157- ; }
158-
190+ }
191+ return this ;
159192 }
160193
161194
162- /**
163- * Constructor takes a Structure object, finds base pair and base-pair step parameters
164- * for double-helical regions within the structure for only canonical DNA pairs.
165- * @param structure The already-loaded structure to analyze.
166- */
167- public BasePairParameters (Structure structure ) {
168- this (structure , false , false );
169- }
170-
171195 /**
172196 * This reports all the pair parameters, in the order of:
173197 * buckle, propeller, opening (in degrees), shear, stagger, stretch (in Å).
@@ -190,7 +214,7 @@ public double[][] getStepParameters() {
190214 /**
191215 * This returns the primary strand's sequence where parameters were found.
192216 * There are spaces in the string anywhere there was a break in the helix or when
193- * it goes from one helix to another helix in the structure. (the "step" is still returned! )
217+ * it goes from one helix to another helix in the structure. (the "step" is still returned)
194218 * @return String of primary sequence with spaces between gaps and new helices.
195219 */
196220 public String getPairSequence () {
@@ -212,7 +236,7 @@ public List<Matrix4d> getReferenceFrames() {
212236
213237 /**
214238 * This reports all the nucleic acid chains and has an option to remove duplicates if you
215- * are considering an analyze of only unique DNA or RNA helices in the Structure.
239+ * are considering an analysis of only unique DNA or RNA helices in the Structure.
216240 * @param removeDups If true, it will ignore duplicate chains
217241 * @return A list of all the nucleic acid chains in order of the Structure
218242 */
@@ -236,7 +260,6 @@ public List<Chain> getNucleicChains(boolean removeDups) {
236260 return result ;
237261 }
238262
239-
240263 /**
241264 * This performs a search for base pairs in the structure. The criteria is alignment of
242265 * sequences and the canonical base pairs of DNA and RNA.
@@ -309,6 +332,11 @@ public List<Group[]> findPairs(List<Chain> chains) {
309332 }
310333
311334
335+ /**
336+ * Calculate the central frame (4x4 transformation matrix) of a single base pair.
337+ * @param pair An array of the two groups that make a hypothetical pair
338+ * @return The middle frame of the center of the base-pair formed
339+ */
312340 public Matrix4d basePairReferenceFrame (Group [] pair ) {
313341 Integer type1 = map .get (pair [0 ].getPDBName ());
314342 Integer type2 = map .get (pair [1 ].getPDBName ());
@@ -407,6 +435,23 @@ public Matrix4d basePairReferenceFrame(Group[] pair) {
407435 }
408436
409437
438+ @ Override
439+ public String toString () {
440+ if (getPairingParameters () == null ) return "No data" ;
441+ StringBuilder result = new StringBuilder (10000 );
442+ result .append (pairingParameters .length + " base pairs\n " );
443+ result .append ("bp: buckle propeller opening shear stretch stagger tilt roll twist shift slide rise\n " );
444+ for (int i = 0 ; i < pairingParameters .length ; i ++) {
445+ result .append (pairingNames .get (i )+": " );
446+ for (int j = 0 ; j < 6 ; j ++)
447+ result .append (String .format ("%5.4f" , pairingParameters [i ][j ]) + " " );
448+ for (int j = 0 ; j < 6 ; j ++)
449+ result .append (String .format ("%5.4f" , stepParameters [i ][j ]) + " " );
450+ result .append ("\n " );
451+ }
452+ return result .toString ();
453+ }
454+
410455
411456 /**
412457 * This method calculates pairing and step parameters from 4x4 transformation matrices
@@ -519,4 +564,13 @@ public static String longestCommonSubstring(String s1, String s2) {
519564 return s1 .substring (start , (start + max ));
520565 }
521566
567+ protected static boolean match (char a , char b , boolean RNA ) {
568+ if (a == 'A' && b == 'T' && !RNA ) return true ;
569+ if (a == 'A' && b == 'U' && RNA ) return true ;
570+ if (a == 'T' && b == 'A' && !RNA ) return true ;
571+ if (a == 'U' && b == 'A' && RNA ) return true ;
572+ if (a == 'G' && b == 'C' ) return true ;
573+ if (a == 'C' && b == 'G' ) return true ;
574+ return false ;
575+ }
522576}
0 commit comments