11package org .biojava .nbio .structure .basepairs ;
22
33import org .biojava .nbio .structure .*;
4+ import org .biojava .nbio .structure .contact .Pair ;
45import org .biojava .nbio .structure .geometry .SuperPosition ;
56import org .biojava .nbio .structure .geometry .SuperPositionQCP ;
67import org .biojava .nbio .structure .io .PDBFileReader ;
2122 * This module calculates the el Hassan-Calladine Base Pairing and Base-pair Step Parameters
2223 * Citation: https://www.ncbi.nlm.nih.gov/pubmed/11601858
2324 *
24- * The method that might be overridden is findPairs(), this implementation is used for a large-scale
25+ * The method that is usually overridden is findPairs(), this implementation is used for a large-scale
2526 * analysis of the most proper helical regions in almost 4000 protein-DNA structures, almost
2627 * 2000 structures containing only DNA, or almost 1300 structures containing only RNA. (as of 7/2017).
27- * Those who study tertiary structures for RNA folding would be better using their own method,
28- * because this is only looking for base pairs between separate strands.
28+ * Those who study tertiary structures for RNA folding should try using the TertiaryBasePairParameters,
29+ * because this base class is only looking for base pairs between separate strands that exactly line up.
30+ * To relax the lining up policy and allow for non-canonical base pairs, use the MismatchedBasePairParameters
31+ * class.
32+ *
33+ * @author Luke Czapla
34+ * @since 5.0.0-snapshot
2935 *
30- * Created by luke czapla on 7/20/17.
3136 */
3237public class BasePairParameters {
3338
3439 private static Logger log = LoggerFactory .getLogger (BasePairParameters .class );
3540
41+
3642 // See URL http://ndbserver.rutgers.edu/ndbmodule/archives/reports/tsukuba/Table1.html
3743 // and the paper cited at the top of this class (also as Table 1).
3844 // These are hard-coded to avoid problems with resource paths.
@@ -171,7 +177,7 @@ public BasePairParameters analyze() {
171177 return this ;
172178 }
173179 List <Chain > nucleics = this .getNucleicChains (nonredundant );
174- List <Group [] > pairs = this .findPairs (nucleics );
180+ List <Pair < Group > > pairs = this .findPairs (nucleics );
175181 this .pairingParameters = new double [pairs .size ()][6 ];
176182 this .stepParameters = new double [pairs .size ()][6 ];
177183 Matrix4d lastStep ;
@@ -192,6 +198,17 @@ public BasePairParameters analyze() {
192198 }
193199
194200
201+
202+ /**
203+ * Returns the total number of base pairs that were found, after the call to analyze()
204+ * @return An integer value, number of base pairs
205+ */
206+ public Integer getLength () {
207+ if (structure == null || pairParameters == null ) throw new IllegalArgumentException ();
208+ return pairingParameters .length ;
209+ }
210+
211+
195212 /**
196213 * This reports all the pair parameters, in the order of:
197214 * buckle, propeller, opening (in degrees), shear, stagger, stretch (in Å).
@@ -211,6 +228,7 @@ public double[][] getStepParameters() {
211228 return stepParameters ;
212229 }
213230
231+
214232 /**
215233 * This returns the primary strand's sequence where parameters were found.
216234 * There are spaces in the string anywhere there was a break in the helix or when
@@ -221,6 +239,7 @@ public String getPairSequence() {
221239 return pairSequence ;
222240 }
223241
242+
224243 /**
225244 * This returns the names of the pairs in terms of A, G, T/U, and C for each base pair group in the
226245 * list. The first character is the leading strand base and the second character is the complementary base
@@ -234,13 +253,14 @@ public List<Matrix4d> getReferenceFrames() {
234253 return referenceFrames ;
235254 }
236255
256+
237257 /**
238258 * Return the buckle in degrees for the given base pair
239259 * @param bp the number of the base pair (starting with 0)
240260 * @return the value as a double (in degrees)
241261 */
242262 public Double getBuckle (int bp ) {
243- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
263+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
244264 return pairingParameters [bp ][0 ];
245265 }
246266
@@ -250,7 +270,7 @@ public Double getBuckle(int bp) {
250270 * @return the value as a double (in degrees)
251271 */
252272 public Double getPropeller (int bp ) {
253- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
273+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
254274 return pairingParameters [bp ][1 ];
255275 }
256276
@@ -260,7 +280,7 @@ public Double getPropeller(int bp) {
260280 * @return the value as a double (in degrees)
261281 */
262282 public Double getOpening (int bp ) {
263- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
283+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
264284 return pairingParameters [bp ][2 ];
265285 }
266286
@@ -270,7 +290,7 @@ public Double getOpening(int bp) {
270290 * @return the value as a double (in Å)
271291 */
272292 public Double getShear (int bp ) {
273- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
293+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
274294 return pairingParameters [bp ][3 ];
275295 }
276296
@@ -280,7 +300,7 @@ public Double getShear(int bp) {
280300 * @return the value as a double (in Å)
281301 */
282302 public Double getStretch (int bp ) {
283- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
303+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
284304 return pairingParameters [bp ][4 ];
285305 }
286306
@@ -290,7 +310,7 @@ public Double getStretch(int bp) {
290310 * @return the value as a double (in Å)
291311 */
292312 public Double getStagger (int bp ) {
293- if (bp < 0 || bp >= getPairingParameters ().length ) return null ;
313+ if (bp < 0 || bp >= getPairingParameters ().length ) throw new IllegalArgumentException () ;
294314 return pairingParameters [bp ][5 ];
295315 }
296316
@@ -300,7 +320,7 @@ public Double getStagger(int bp) {
300320 * @return the value as a double (in degrees)
301321 */
302322 public Double getTilt (int bp ) {
303- if (bp < 0 || bp >= getStepParameters ().length ) return null ;
323+ if (bp < 0 || bp >= getStepParameters ().length ) throw new IllegalArgumentException () ;
304324 return stepParameters [bp ][0 ];
305325 }
306326
@@ -310,7 +330,7 @@ public Double getTilt(int bp) {
310330 * @return the value as a double (in degrees)
311331 */
312332 public Double getRoll (int bp ) {
313- if (bp < 0 || bp >= getStepParameters ().length ) return null ;
333+ if (bp < 0 || bp >= getStepParameters ().length ) throw new IllegalArgumentException () ;
314334 return stepParameters [bp ][1 ];
315335 }
316336
@@ -320,7 +340,7 @@ public Double getRoll(int bp) {
320340 * @return the value as a double (in degrees)
321341 */
322342 public Double getTwist (int bp ) {
323- if (bp < 0 || bp >= getStepParameters ().length ) return null ;
343+ if (bp < 0 || bp >= getStepParameters ().length ) throw new IllegalArgumentException () ;
324344 return stepParameters [bp ][2 ];
325345 }
326346
@@ -330,7 +350,7 @@ public Double getTwist(int bp) {
330350 * @return the value as a double (in Å)
331351 */
332352 public Double getShift (int bp ) {
333- if (bp < 0 || bp >= getStepParameters ().length ) return null ;
353+ if (bp < 0 || bp >= getStepParameters ().length ) throw new IllegalArgumentException () ;
334354 return stepParameters [bp ][3 ];
335355 }
336356
@@ -340,7 +360,7 @@ public Double getShift(int bp) {
340360 * @return the value as a double (in Å)
341361 */
342362 public Double getSlide (int bp ) {
343- if (bp < 0 || bp >= getStepParameters ().length ) return null ;
363+ if (bp < 0 || bp >= getStepParameters ().length ) throw new IllegalArgumentException () ;
344364 return stepParameters [bp ][4 ];
345365 }
346366
@@ -389,8 +409,8 @@ public List<Chain> getNucleicChains(boolean removeDups) {
389409 * @return The list of corresponding Watson-Crick groups as pairs, element 0 is on the
390410 * forward strand and element 1 is on the reverse strand.
391411 */
392- public List <Group [] > findPairs (List <Chain > chains ) {
393- List <Group [] > result = new ArrayList <>();
412+ public List <Pair < Group > > findPairs (List <Chain > chains ) {
413+ List <Pair < Group > > result = new ArrayList <>();
394414 for (int i = 0 ; i < chains .size (); i ++) {
395415 Chain c = chains .get (i );
396416 for (int j = i +1 ; j < chains .size (); j ++) {
@@ -439,7 +459,7 @@ public List<Group[]> findPairs(List<Chain> chains) {
439459 if (a == null ) valid = false ;
440460 }
441461 if (valid ) {
442- result .add (new Group []{ g1 , g2 } );
462+ result .add (new Pair < Group >( g1 , g2 ) );
443463 pairingNames .add ((useRNA ? baseListRNA [type1 ]+baseListRNA [type2 ] : baseListDNA [type1 ]+baseListDNA [type2 ]));
444464 pairSequence += c .getAtomSequence ().charAt (index1 + k );
445465 } else if (pairSequence .length () != 0 && pairSequence .charAt (pairSequence .length ()-1 ) != ' ' ) pairSequence += ' ' ;
@@ -459,9 +479,9 @@ public List<Group[]> findPairs(List<Chain> chains) {
459479 * @param pair An array of the two groups that make a hypothetical pair
460480 * @return The middle frame of the center of the base-pair formed
461481 */
462- public Matrix4d basePairReferenceFrame (Group [] pair ) {
463- Integer type1 = map .get (pair [ 0 ] .getPDBName ());
464- Integer type2 = map .get (pair [ 1 ] .getPDBName ());
482+ public Matrix4d basePairReferenceFrame (Pair < Group > pair ) {
483+ Integer type1 = map .get (pair . getFirst () .getPDBName ());
484+ Integer type2 = map .get (pair . getSecond () .getPDBName ());
465485 SuperPosition sp = new SuperPositionQCP (true );
466486 if (type1 == null || type2 == null ) return null ;
467487 PDBFileReader pdbFileReader = new PDBFileReader ();
@@ -481,9 +501,9 @@ public Matrix4d basePairReferenceFrame(Group[] pair) {
481501 int count = 0 ;
482502
483503 for (Atom a : std1 .getAtoms ()) {
484- if (pair [ 0 ] .getAtom (a .getName ()) == null ) return null ;
504+ if (pair . getFirst () .getAtom (a .getName ()) == null ) return null ;
485505 pointref [count ] = a .getCoordsAsPoint3d ();
486- pointact [count ] = pair [ 0 ] .getAtom (a .getName ()).getCoordsAsPoint3d ();
506+ pointact [count ] = pair . getFirst () .getAtom (a .getName ()).getCoordsAsPoint3d ();
487507 count ++;
488508 }
489509 assert count == std1 .getAtoms ().size ();
@@ -494,9 +514,9 @@ public Matrix4d basePairReferenceFrame(Group[] pair) {
494514
495515 count = 0 ;
496516 for (Atom a : std2 .getAtoms ()) {
497- if (pair [ 1 ] .getAtom (a .getName ()) == null ) return null ;
517+ if (pair . getSecond () .getAtom (a .getName ()) == null ) return null ;
498518 pointref [count ] = a .getCoordsAsPoint3d ();
499- pointact [count ] = pair [ 1 ] .getAtom (a .getName ()).getCoordsAsPoint3d ();
519+ pointact [count ] = pair . getSecond () .getAtom (a .getName ()).getCoordsAsPoint3d ();
500520 count ++;
501521 }
502522 assert count == std2 .getAtoms ().size ();
0 commit comments