Skip to content

Commit a182c8d

Browse files
luke czaplaluke czapla
authored andcommitted
Full sentence revision of all JavaDoc and addition of separate error checking method
1 parent 4908343 commit a182c8d

4 files changed

Lines changed: 68 additions & 51 deletions

File tree

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

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@
4848
import static java.lang.Math.PI;
4949

5050
/**
51-
* Contributed to BioJava under its LGPL
52-
* This module calculates the el Hassan-Calladine Base Pairing and Base-pair Step Parameters
51+
* This module calculates the el Hassan-Calladine Base Pairing and Base-pair Step Parameters for any nucleic
52+
* acid containing structure that has the information about the core base-pair rings.
5353
* Citation: https://www.ncbi.nlm.nih.gov/pubmed/11601858
5454
*
55-
* The method that is usually overridden is findPairs(), this implementation is used for a large-scale
55+
* The method that is usually overridden is findPairs(), this base implementation is used for a large-scale
5656
* analysis of the most proper helical regions in almost 4000 protein-DNA structures, almost
5757
* 2000 structures containing only DNA, or almost 1300 structures containing only RNA. (as of 7/2017).
58-
* Those who study tertiary structures for RNA folding should try using the TertiaryBasePairParameters,
58+
* Those who study tertiary structures for RNA folding should use the TertiaryBasePairParameters,
5959
* because this base class is only looking for base pairs between separate strands that exactly line up.
6060
* To relax the lining up policy and allow for non-canonical base pairs, use the MismatchedBasePairParameters
61-
* class.
61+
* class, which will not consider intra-strand base pairing.
6262
*
6363
* @author Luke Czapla
6464
* @since 5.0.0
@@ -147,7 +147,7 @@ public class BasePairParameters implements Serializable {
147147
protected boolean nonredundant = false;
148148
protected double[] pairParameters;
149149

150-
// this is the main data that you want to get back out from the procedure.
150+
// this is the main data that the user wants to get back out from the procedure.
151151
protected String pairSequence = "";
152152
protected double[][] pairingParameters;
153153
protected double[][] stepParameters;
@@ -156,7 +156,7 @@ public class BasePairParameters implements Serializable {
156156

157157

158158
/**
159-
* Constructor takes a Structure object, finds base pair and base-pair step parameters
159+
* This constructor takes a Structure object, finds base pair and base-pair step parameters
160160
* for double-helical regions within the structure.
161161
* @param structure The already-loaded structure to analyze.
162162
* @param useRNA whether to look for canonical RNA pairs. By default (false) it analyzes DNA.
@@ -173,7 +173,7 @@ public BasePairParameters(Structure structure, boolean useRNA, boolean removeDup
173173
}
174174

175175
/**
176-
* Constructor takes a Structure object, whether to use RNA, and whether to remove duplicate sequences.
176+
* This constructor takes a Structure object, whether to use RNA, and whether to remove duplicate sequences.
177177
* @param structure The already-loaded structure to analyze.
178178
* @param useRNA if true, the RNA standard bases will be used. Otherwise, if false, it will work on standard DNA bases.
179179
* @param removeDups if true, duplicate sequences will not be considered. This is for the analysis of X-ray structures from
@@ -184,7 +184,7 @@ public BasePairParameters(Structure structure, boolean useRNA, boolean removeDup
184184
}
185185

186186
/**
187-
* Constructor takes a Structure object, and whether to use the RNA standard bases
187+
* This constructor takes a Structure object, and whether to use the RNA standard bases.
188188
* @param structure The already-loaded structure to analyze.
189189
* @param useRNA if true, the RNA standard bases will be used. Otherwise, if false, it will work on standard DNA bases.
190190
*/
@@ -193,7 +193,7 @@ public BasePairParameters(Structure structure, boolean useRNA) {
193193
}
194194

195195
/**
196-
* Constructor takes a Structure object, finds base pair and base-pair step parameters
196+
* This constructor takes a Structure object, finds base pair and base-pair step parameters
197197
* for double-helical regions within the structure for only canonical DNA pairs.
198198
* @param structure The already-loaded structure to analyze.
199199
*/
@@ -203,7 +203,7 @@ public BasePairParameters(Structure structure) {
203203

204204

205205
/**
206-
* This is the main function call to extract all step parameters, pairing parameters, and sequence
206+
* This method is the main function call to extract all step parameters, pairing parameters, and sequence
207207
* information from the Structure object provided to the constructor.
208208
* @return This same object with the populated data, convenient for output
209209
* (e.g. <i>log.info(new BasePairParameters(structure).analyze());</i>)
@@ -238,17 +238,17 @@ public BasePairParameters analyze() {
238238

239239

240240
/**
241-
* Returns the total number of base pairs that were found, after the call to analyze()
241+
* This method returns the total number of base pairs that were found, used after the call to analyze().
242242
* @return An integer value, number of base pairs
243243
*/
244244
public int getLength() {
245-
if (structure == null || pairParameters == null) throw new IllegalArgumentException("Base pair number is out of range.");
245+
if (structure == null || pairParameters == null) throw new IllegalArgumentException("This structure is not analyzed or not initialized.");
246246
return pairingParameters.length;
247247
}
248248

249249

250250
/**
251-
* This reports all the pair parameters, in the order of:
251+
* This method reports all the pair parameters, in the order of:
252252
* buckle, propeller, opening (in degrees), shear, stagger, stretch (in Å).
253253
* @return A double[][] with length equal to number of base pairs for rows, and 6 columns
254254
*/
@@ -257,7 +257,7 @@ public double[][] getPairingParameters() {
257257
}
258258

259259
/**
260-
* This reports all the base-pair step parameters, in the order of:
260+
* This method reports all the base-pair step parameters, in the order of:
261261
* tilt, roll, twist (in degrees), shift, slide, rise (in Å).
262262
* @return A double[][] with length equal to number of base pairs (the first row 0 has no step
263263
* and therefore is six zeroes), and 6 columns.
@@ -268,7 +268,7 @@ public double[][] getStepParameters() {
268268

269269

270270
/**
271-
* This returns the primary strand's sequence where parameters were found.
271+
* This method returns the primary strand's sequence where parameters were found.
272272
* There are spaces in the string anywhere there was a break in the helix or when
273273
* it goes from one helix to another helix in the structure. (the "step" is still returned)
274274
* @return String of primary sequence with spaces between gaps and new helices.
@@ -279,7 +279,7 @@ public String getPairSequence() {
279279

280280

281281
/**
282-
* This returns the names of the pairs in terms of A, G, T/U, and C for each base pair group in the
282+
* This method returns the names of the pairs in terms of A, G, T/U, and C for each base pair group in the
283283
* list. The first character is the leading strand base and the second character is the complementary base
284284
* @return
285285
*/
@@ -291,79 +291,87 @@ public List<Matrix4d> getReferenceFrames() {
291291
return referenceFrames;
292292
}
293293

294+
/**
295+
* This method is an internal test that the base pair specified is within a valid range. If not, it throws an exception
296+
* with a message.
297+
* @param bp The index of the base pair or base-pair step to return.
298+
*/
299+
private void checkArgument(int bp) {
300+
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
301+
}
294302

295303
/**
296-
* Return the buckle in degrees for the given base pair
304+
* This method returns the buckle in degrees for the given base pair
297305
* @param bp the number of the base pair (starting with 0)
298306
* @return the value as a double (in degrees)
299307
*/
300308
public Double getBuckle(int bp) {
301-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
309+
checkArgument(bp);
302310
return pairingParameters[bp][0];
303311
}
304312

305313
/**
306-
* Return the propeller ("propeller-twist") in degrees for the given base pair
314+
* This method returns the propeller ("propeller-twist") in degrees for the given base pair
307315
* @param bp the number of the base pair (starting with 0)
308316
* @return the value as a double (in degrees)
309317
*/
310318
public Double getPropeller(int bp) {
311-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
319+
checkArgument(bp);
312320
return pairingParameters[bp][1];
313321
}
314322

315323
/**
316-
* Return the opening in degrees for the given base pair
324+
* This method returns the opening in degrees for the given base pair
317325
* @param bp the number of the base pair (starting with 0)
318326
* @return the value as a double (in degrees)
319327
*/
320328
public Double getOpening(int bp) {
321-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
329+
checkArgument(bp);
322330
return pairingParameters[bp][2];
323331
}
324332

325333
/**
326-
* Return the shear in Å for the given base pair
334+
* This method returns the shear in Å for the given base pair
327335
* @param bp the number of the base pair (starting with 0)
328336
* @return the value as a double (in Å)
329337
*/
330338
public Double getShear(int bp) {
331-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
339+
checkArgument(bp);
332340
return pairingParameters[bp][3];
333341
}
334342

335343
/**
336-
* Return the stretch in Å for the given base pair
344+
* This method returns the stretch in Å for the given base pair
337345
* @param bp the number of the base pair (starting with 0)
338346
* @return the value as a double (in Å)
339347
*/
340348
public Double getStretch(int bp) {
341-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
349+
checkArgument(bp);
342350
return pairingParameters[bp][4];
343351
}
344352

345353
/**
346-
* Return the stagger in Å for the given base pair
354+
* This method returns the stagger in Å for the given base pair
347355
* @param bp the number of the base pair (starting with 0)
348356
* @return the value as a double (in Å)
349357
*/
350358
public Double getStagger(int bp) {
351-
if (bp < 0 || bp >= getPairingParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
359+
checkArgument(bp);
352360
return pairingParameters[bp][5];
353361
}
354362

355363
/**
356-
* Return the tilt for the given base pair, relative to the one before it.
364+
* This method returns the tilt for the given base pair, relative to the one before it.
357365
* @param bp the number of the base pair (starting with 0)
358366
* @return the value as a double (in degrees)
359367
*/
360368
public Double getTilt(int bp) {
361-
if (bp < 0 || bp >= getStepParameters().length) throw new IllegalArgumentException("Base pair number is out of range.");
369+
checkArgument(bp);
362370
return stepParameters[bp][0];
363371
}
364372

365373
/**
366-
* Return the roll for the given base pair, relative to the one before it.
374+
* This method returns the roll for the given base pair, relative to the one before it.
367375
* @param bp the number of the base pair (starting with 0)
368376
* @return the value as a double (in degrees)
369377
*/
@@ -373,7 +381,7 @@ public Double getRoll(int bp) {
373381
}
374382

375383
/**
376-
* Return the twist for the given base pair, relative to the one before it.
384+
* This method returns the twist for the given base pair, relative to the one before it.
377385
* @param bp the number of the base pair (starting with 0)
378386
* @return the value as a double (in degrees)
379387
*/
@@ -393,7 +401,7 @@ public Double getShift(int bp) {
393401
}
394402

395403
/**
396-
* Return the slide for the given base pair, relative to the one before it.
404+
* This method returns the slide for the given base pair, relative to the one before it.
397405
* @param bp the number of the base pair (starting with 0)
398406
* @return the value as a double (in Å)
399407
*/
@@ -403,7 +411,7 @@ public Double getSlide(int bp) {
403411
}
404412

405413
/**
406-
* Return the rise for the given base pair, relative to the one before it.
414+
* This method returns the rise for the given base pair, relative to the one before it.
407415
* @param bp the number of the base pair (starting with 0)
408416
* @return the value as a double (in Å)
409417
*/
@@ -414,7 +422,7 @@ public Double getRise(int bp) {
414422

415423

416424
/**
417-
* This reports all the nucleic acid chains and has an option to remove duplicates if you
425+
* This method reports all the nucleic acid chains and has an option to remove duplicates if you
418426
* are considering an analysis of only unique DNA or RNA helices in the Structure.
419427
* @param removeDups If true, it will ignore duplicate chains
420428
* @return A list of all the nucleic acid chains in order of the Structure
@@ -440,7 +448,7 @@ public List<Chain> getNucleicChains(boolean removeDups) {
440448
}
441449

442450
/**
443-
* This performs a search for base pairs in the structure. The criteria is alignment of
451+
* This method performs a search for base pairs in the structure. The criteria is alignment of
444452
* sequences and the canonical base pairs of DNA or RNA. Use MismatchedBasePairParameters
445453
* or TertiaryBasePairParameters for finding higher-order associations.
446454
* @param chains The list of chains already found to be nucleic acids
@@ -514,7 +522,7 @@ public List<Pair<Group>> findPairs(List<Chain> chains) {
514522

515523

516524
/**
517-
* Calculate the central frame (4x4 transformation matrix) of a single base pair.
525+
* This method calculates the central frame (4x4 transformation matrix) of a single base pair.
518526
* @param pair An array of the two groups that make a hypothetical pair
519527
* @return The middle frame of the center of the base-pair formed
520528
*/
@@ -636,7 +644,7 @@ public String toString() {
636644
// The following methods are just helper classes for the rapid analyze of base-pair geometry.
637645
/**
638646
* This method calculates pairing and step parameters from 4x4 transformation matrices (used internally)
639-
* that come out as Matrix4d;
647+
* that comes out as a Matrix4d.
640648
* @param input the 4x4 matrix representing the transformation from strand II -> strand I or pair i to pair i+1
641649
* @return Six parameters as double[6]
642650
*/
@@ -686,7 +694,7 @@ public static double[] calculateTp(Matrix4d input) {
686694
}
687695

688696
/**
689-
* Return the complement of a base (used internally)
697+
* This method returns the complement of a base. (used internally)
690698
* @param base The letter of the base
691699
* @param RNA Whether it is RNA (if false, it is DNA)
692700
* @return The character representing the complement of the base
@@ -714,7 +722,7 @@ private static String complement(String sequence, boolean RNA) {
714722
}
715723

716724
/**
717-
* 3D Vector cross product of two vectors as double arrays (used internally)
725+
* This does a 3D Vector cross product of two vectors as double arrays. (used internally)
718726
*
719727
* @param a An array of length 3 or 4 (4th component is ignored)
720728
* @param b An array of length 3 or 4 (4th component is ignored)
@@ -730,7 +738,7 @@ private static double[] cross(double[] a, double[] b) {
730738
}
731739

732740
/**
733-
* Remove any component of vector a that is along vector b (used internally)
741+
* This method removes any component of vector a that is along vector b. (used internally)
734742
* @param a The array (vector) to remove component from
735743
* @param b The component array (vector) to remove from the first
736744
* @return The original array a with any component along b removed from it.
@@ -749,7 +757,7 @@ private static double[] removeComponent(double[] a, double[] b) {
749757
}
750758

751759
/**
752-
* Finds the longest common substring between two strings (used internally)
760+
* This method finds the longest common substring between two strings. (used internally)
753761
* @param s1 The first string
754762
* @param s2 The second string
755763
* @return The substring itself
@@ -774,7 +782,7 @@ private static String longestCommonSubstring(String s1, String s2) {
774782
}
775783

776784
/**
777-
* Return true if a is the complement of b (used internally)
785+
* This returns true if a is the complement of b, false otherwise. (used internally)
778786
* @param a First letter
779787
* @param b Potential matching letter
780788
* @param RNA Whether it is RNA (if false, DNA rules are used)

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
/**
3636
* This class allows for finding inter-strand base pairs that are not necessarily canonical Watson-Crick pairs.
37-
* The implementation of findPair is different than that of the base class.
37+
* The implementation of findPair is different than that of the base class. This class does not consider intra-strand
38+
* base pairing and for that, the TertiaryBasePairParameters class should be used.
3839
* @author Luke Czapla
3940
* @since 5.0.0
4041
*
@@ -45,6 +46,15 @@ public class MismatchedBasePairParameters extends BasePairParameters implements
4546
protected static double MaxStagger = 2.0, MaxShear = 5.0, MaxStretch = 5.0,
4647
MaxPropeller = 60.0;
4748

49+
/**
50+
* This constructor is used to create the TertiaryBasePairParameters object. The parent constructors are valid
51+
* as well, but for this class, it makes the most sense to specify the exact parameters for the analysis.
52+
* @param structure The Structure to analyze
53+
* @param RNA Whether to analyze RNA (if false, it will analyze DNA)
54+
* @param removeDups Whether to remove duplicate sequences (useful for RCSB data with redundant units).
55+
* @param canonical Whether to only consider canonical Watson-Crick base pairs. If false, any pairing will be identified
56+
* as long it falls below the maximum values of stagger, shear, and stretch.
57+
*/
4858
public MismatchedBasePairParameters(Structure structure, boolean RNA, boolean removeDups, boolean canonical) {
4959

5060
super(structure, RNA, removeDups, canonical);
@@ -53,8 +63,8 @@ public MismatchedBasePairParameters(Structure structure, boolean RNA, boolean re
5363

5464
/**
5565
* This is an implementation for finding non-canonical base pairs when there may be missing or overhanging bases.
56-
* @param chains The list of chains already found to be nucleic acids
57-
* @return The list of the atom groups (residues) that are pairs, as a Pair of nucleic acid Groups
66+
* @param chains The list of chains already found to be nucleic acids.
67+
* @return The list of the atom groups (residues) that are pairs, as a Pair of nucleic acid Groups.
5868
*/
5969
@Override
6070
public List<Pair<Group>> findPairs(List<Chain> chains) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/**
3636
* This class also finds the base pairing and base-pair step parameters but has a broader definition
3737
* of a base pair so that non-canonical-WC base pairs will be detected and reported. This is useful
38-
* for RNA that has folded into different regions, and into higher order DNA structures. Intra-strand
38+
* for RNA that has folded into different regions, and for higher-order DNA structures. Intra-strand
3939
* pairings are considered in this class (but in not the base class or MismatchedBasePairParameters class)
4040
* @author Luke Czapla
4141
* @since 5.0.0

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
import static org.junit.Assert.*;
3434

3535
/**
36-
* Contributed to BioJava under it's LGPL
3736
* This class tests the implementations of the search for base pairs for different RCSB structures
38-
* and the tests uses 3DNA as a comparator program. (other programs such as CURVES and NEWHELIX exist but
39-
* this implementation is closest to that of 3DNA).
37+
* and the tests uses 3DNA as a comparator program. (other programs such as CURVES and NEWHELIX work similarly but
38+
* this implementation is closest to that of 3DNA)
4039
* @author Luke Czapla
4140
* @since 5.0.0
4241
*

0 commit comments

Comments
 (0)