Skip to content

Commit d09b552

Browse files
luke czaplaluke czapla
authored andcommitted
Added author line and other suggestions
1 parent 9650e13 commit d09b552

File tree

4 files changed

+74
-41
lines changed

4 files changed

+74
-41
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/basepairs/BasePairParameters.java

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.biojava.nbio.structure.basepairs;
22

33
import org.biojava.nbio.structure.*;
4+
import org.biojava.nbio.structure.contact.Pair;
45
import org.biojava.nbio.structure.geometry.SuperPosition;
56
import org.biojava.nbio.structure.geometry.SuperPositionQCP;
67
import org.biojava.nbio.structure.io.PDBFileReader;
@@ -21,18 +22,23 @@
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
*/
3237
public 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();

biojava-structure/src/main/java/org/biojava/nbio/structure/basepairs/MismatchedBasePairParameters.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.biojava.nbio.structure.Chain;
55
import org.biojava.nbio.structure.Group;
66
import org.biojava.nbio.structure.Structure;
7+
import org.biojava.nbio.structure.contact.Pair;
78

89
import javax.vecmath.Matrix4d;
910
import java.util.ArrayList;
@@ -13,10 +14,15 @@
1314
* Contributed to BioJava under its LGPL
1415
* This class allows for finding inter-strand base pairs that are not necessarily canonical Watson-Crick pairs.
1516
* The implementation of findPair is different than that of the base class.
16-
* Created by luke on 7/23/17.
17+
* @author Luke Czapla
18+
* @since 5.0.0-snapshot
19+
*
1720
*/
1821
public class MismatchedBasePairParameters extends BasePairParameters {
1922

23+
protected static final double MaxStagger = 2.0, MaxShear = 5.0, MaxStretch = 5.0,
24+
MaxPropeller = 60.0;
25+
2026
public MismatchedBasePairParameters(Structure structure, boolean RNA, boolean removeDups, boolean canonical) {
2127

2228
super(structure, RNA, removeDups, canonical);
@@ -29,8 +35,8 @@ public MismatchedBasePairParameters(Structure structure, boolean RNA, boolean re
2935
* @return The list of the atom groups (residues) that are pairs, a Group[2] array
3036
*/
3137
@Override
32-
public List<Group[]> findPairs(List<Chain> chains) {
33-
List<Group[]> result = new ArrayList<>();
38+
public List<Pair<Group>> findPairs(List<Chain> chains) {
39+
List<Pair<Group>> result = new ArrayList<>();
3440
boolean lastFoundPair = false;
3541
for (int i = 0; i < chains.size(); i++) {
3642
Chain c = chains.get(i);
@@ -54,15 +60,15 @@ public List<Group[]> findPairs(List<Chain> chains) {
5460
if (a1 == null || a2 == null) continue;
5561
// C1'-C1' distance is one useful criteria
5662
if (Math.abs(a1.getCoordsAsPoint3d().distance(a2.getCoordsAsPoint3d()) - 10.0) > 3.0) continue;
57-
Group[] ga = new Group[]{g1, g2};
63+
Pair<Group> ga = new Pair<>(g1, g2);
5864
Matrix4d data = basePairReferenceFrame(ga);
5965
// if the stagger is greater than 2 Å, it's not really paired.
60-
if (Math.abs(pairParameters[5]) > 2.0) continue;
61-
if (Math.abs(pairParameters[3]) > 5.0) continue;
62-
if (Math.abs(pairParameters[4]) > 5.0) continue;
66+
if (Math.abs(pairParameters[5]) > MaxStagger) continue;
67+
if (Math.abs(pairParameters[3]) > MaxShear) continue;
68+
if (Math.abs(pairParameters[4]) > MaxStretch) continue;
6369

6470
// if the propeller is ridiculous it's also not that good of a pair.
65-
if (Math.abs(pairParameters[1]) > 60.0) {
71+
if (Math.abs(pairParameters[1]) > MaxPropeller) {
6672
continue;
6773
}
6874
result.add(ga);

biojava-structure/src/main/java/org/biojava/nbio/structure/basepairs/TertiaryBasePairParameters.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@
44
import org.biojava.nbio.structure.Chain;
55
import org.biojava.nbio.structure.Group;
66
import org.biojava.nbio.structure.Structure;
7+
import org.biojava.nbio.structure.contact.Pair;
78

89
import javax.vecmath.Matrix4d;
910
import java.util.ArrayList;
1011
import java.util.List;
1112

1213
/**
1314
* Contributed to BioJava under it's LGPL
14-
* Created by luke czapla on 7/22/17.
1515
* This class also finds the base pairing and base-pair step parameters but has a broader definition
1616
* of a base pair so that non-canonical-WC base pairs will be detected and reported. This is useful
1717
* for RNA that has folded into different regions.
18+
* @author Luke Czapla
19+
* @since 5.0.0-snapshot
20+
*
1821
*/
1922
public class TertiaryBasePairParameters extends BasePairParameters {
2023

24+
protected static final double MaxStagger = 2.0, MaxPropeller = 60.0;
25+
2126
public TertiaryBasePairParameters(Structure structure, boolean RNA, boolean removeDups) {
2227
super(structure, RNA, removeDups);
2328
}
@@ -29,8 +34,8 @@ public TertiaryBasePairParameters(Structure structure, boolean RNA, boolean remo
2934
* @return
3035
*/
3136
@Override
32-
public List<Group[]> findPairs(List<Chain> chains) {
33-
List<Group[]> result = new ArrayList<>();
37+
public List<Pair<Group>> findPairs(List<Chain> chains) {
38+
List<Pair<Group>> result = new ArrayList<>();
3439
boolean lastFoundPair = false;
3540
for (int i = 0; i < chains.size(); i++) {
3641
Chain c = chains.get(i);
@@ -49,12 +54,12 @@ public List<Group[]> findPairs(List<Chain> chains) {
4954
if (a1 == null || a2 == null) continue;
5055
// C1'-C1' distance is one useful criteria
5156
if (Math.abs(a1.getCoordsAsPoint3d().distance(a2.getCoordsAsPoint3d())-10.0) > 5.0) continue;
52-
Group[] ga = new Group[] {g1, g2};
57+
Pair<Group> ga = new Pair<>(g1, g2);
5358
Matrix4d data = basePairReferenceFrame(ga);
5459
// if the stagger is greater than 2 Å, it's not really paired.
55-
if (Math.abs(pairParameters[5]) > 2.0) continue;
60+
if (Math.abs(pairParameters[5]) > MaxStagger) continue;
5661
// if the propeller is ridiculous it's also not that good of a pair.
57-
if (Math.abs(pairParameters[1]) > 60.0) {
62+
if (Math.abs(pairParameters[1]) > MaxPropeller) {
5863
continue;
5964
}
6065
result.add(ga);

biojava-structure/src/test/java/org/biojava/nbio/structure/basepairs/TestBasePairParameters.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
/**
1414
* Contributed to BioJava under it's LGPL
15-
* Created by luke czapla on 7/21/17.
15+
* This class tests the implementations of the search for base pairs for different RCSB structures
16+
* and uses 3DNA as a comparator program.
17+
* @author Luke Czapla
1618
*/
1719
public class TestBasePairParameters {
1820

0 commit comments

Comments
 (0)