33import java .util .Comparator ;
44
55/**
6- * Object for storing reads of a BED file
6+ * Object for storing BED-formatted records from a file
77 *
88 * @author William KM Lai
9- * @see scriptmanager.objects.CoordinateObjects.GenomicCoord
9+ * @see scriptmanager.util.BEDUtilities
10+ * @see scriptmanager.util.BAMUtilities
11+ * @see scriptmanager.scripts.Coordinate_Manipulation.BED_Manipulation.SortBED
12+ * @see scriptmanager.scripts.Peak_Analysis.FilterBEDbyProximity
13+ * @see scriptmanager.scripts.Peak_Analysis.RandomCoordinate
14+ * @see scriptmanager.scripts.Peak_Analysis.TileGenome
15+ * @see scriptmanager.scripts.Read_Analysis.ScalingFactor
16+ * @see scriptmanager.scripts.Read_Analysis.TagPileup
17+ * @see scriptmanager.scripts.Sequence_Analysis.DNAShapefromBED
18+ * @see scriptmanager.scripts.Sequence_Analysis.FASTAExtract
1019 */
1120public class BEDCoord implements GenomicCoord {
1221 private String CHROM = "" ;
@@ -21,15 +30,16 @@ public class BEDCoord implements GenomicCoord {
2130
2231 private double [] Fstrand = null ;
2332 private double [] Rstrand = null ;
24-
33+
2534 /**
2635 * Creates a new BEDCoord object with default values
2736 */
2837 public BEDCoord () {}
29-
38+
3039 /**
31- * Creates a new BEDCoord object with a given line of a BED file
32- * @param line Line to parse in order to create BEDCoord file
40+ * Instantiate object from a BED-formatted string
41+ *
42+ * @param line BED-formatted string to parse
3343 */
3444 public BEDCoord (String line ) {
3545 String [] bed = line .split ("\t " );
@@ -45,12 +55,13 @@ public BEDCoord(String line) {
4555 }
4656
4757 /**
48- * Creates a new BEDCoord object
49- * @param c Chromosome name
50- * @param sta Start coordinate
51- * @param sto Ending coordinate
52- * @param di Strand direction (+/-)
53- * @param na Name of coord
58+ * Instantiate object from coordinate values
59+ *
60+ * @param c the chromosome name
61+ * @param sta start coordinate (0-based, inclusive)
62+ * @param sto stop coordinate (0-based, exclusive)
63+ * @param di direction/strand information
64+ * @param na record name
5465 */
5566 public BEDCoord (String c , long sta , long sto , String di , String na ) {
5667 CHROM = c ;
@@ -61,11 +72,12 @@ public BEDCoord(String c, long sta, long sto, String di, String na) {
6172 }
6273
6374 /**
64- * Creates a new BEDCoord object
65- * @param c Chromosome name
66- * @param sta Start coordinate
67- * @param sto Ending coordinate
68- * @param di Strand direction (+/-)
75+ * Instantiate nameless object from coordinate values
76+ *
77+ * @param c the chromosome name
78+ * @param sta start coordinate (0-based, inclusive)
79+ * @param sto stop coordinate (0-based, exclusive)
80+ * @param di the direction/strand information
6981 */
7082 public BEDCoord (String c , long sta , long sto , String di ) {
7183 CHROM = c ;
@@ -76,175 +88,191 @@ public BEDCoord(String c, long sta, long sto, String di) {
7688 }
7789
7890 /**
79- * Creates a new BEDCoord object with a name and score
80- * @param na Name of coord
81- * @param sco Score
91+ * Instantiate object with just name and score
92+ *
93+ * @param na record name
94+ * @param sco record score
8295 */
8396 public BEDCoord (String na , double sco ) {
8497 NAME = na ;
8598 SCORE = sco ;
8699 }
87100
88101 /**
89- * Calculates the middle position of a BED coordinate pair
102+ * calculates a midpoint based on the start and stop coordinates, strand agnostic (left select if even interval)
90103 */
91104 public void calcMid () {
92105 MID = (START + STOP ) / 2 ;
93106 }
94-
107+
95108 /**
96- * Sets the middle position of a BED coordinate pair
97- * @param m New middle position
109+ * set the midpoint coordinate
110+ *
111+ * @param m midpoint coordinate (overwrite)
98112 */
99113 public void setMid (int m ) {
100114 MID = m ;
101115 }
102-
116+
103117 /**
104- * Returns the middle position of a BED coordinate pair
105- * @return The middle position of a BED coordinate pair
118+ * get the stored midpoint coordinate
119+ *
120+ * @return midpoint coordinate
106121 */
107122 public long getMid () {
108123 return MID ;
109124 }
110-
125+
111126 /**
112- * Returns the Pileup scores for the forward strand
113- * @return The Pileup scores for the forward strand
127+ * get forward/combined strand pileup counts
128+ *
129+ * @return the stored forward/combined strand counts
114130 */
115131 public double [] getFStrand () {
116132 return Fstrand ;
117133 }
118-
134+
119135 /**
120- * Returns the Pileup scores for the reverse strand
121- * @return The Pileup scores for the reverse strand
136+ * get reverse strand pileup counts
137+ *
138+ * @return the stored reverse strand counts
122139 */
123140 public double [] getRStrand () {
124141 return Rstrand ;
125142 }
126143
127144 /**
128- * Sets the Pileup scores for the forward strand
129- * @param f The Pileup scores for the forward strand
145+ * set forward/combined strand pileup counts
146+ *
147+ * @param f a list of forward/combined strand counts
130148 */
131149 public void setFstrand (double [] f ) {
132150 Fstrand = f ;
133151 }
134152
135153 /**
136- * Sets the Pileup scores for the reverse strand
137- * @param r The Pileup scores for the reverse strand
154+ * set reverse strand pileup counts
155+ * @param r a list of reverse strand counts
138156 */
139157 public void setRstrand (double [] r ) {
140158 Rstrand = r ;
141159 }
142160
143161 /**
144- * Returns the chromosome name
145- * @return the stored chromosome
162+ * get chromosome name
163+ *
164+ * @return chromosome name
146165 */
147166 public String getChrom () {
148167 return CHROM ;
149168 }
150169
151170 /**
152- * Sets the chromosome name
153- * @param chr The new chromosome
171+ * set chromosome name
172+ *
173+ * @param chr chromosome name
154174 */
155175 public void setChrom (String chr ) {
156176 CHROM = chr ;
157177 }
158178
159179 /**
160- * Returns the starting coordinate of the BEDCoord
161- * @return the starting coordinate of the BEDCord
180+ * get start coordinate
181+ *
182+ * @return start coordinate (0-indexed, inclusive)
162183 */
163184 public long getStart () {
164185 return START ;
165186 }
166187
167188 /**
168- * Sets the starting coordinate of the BEDCoord
169- * @param sta The starting coordinate of the BEDCord
189+ * set start coordinate
190+ *
191+ * @param sta start coordinate (0-indexed, inclusive)
170192 */
171193 public void setStart (int sta ) {
172194 START = sta ;
173195 }
174196
175197 /**
176- * Returns the ending coordinate of the BEDCoord
177- * @return the ending coordinate of the BEDCoord
198+ * get end coordinatec
199+ *
200+ * @return end coordinate (0-indexed, inclusive)
178201 */
179202 public long getStop () {
180203 return STOP ;
181204 }
182205
183206 /**
184- * Sets the ending coordinate of the BEDCoord
185- * @param sto The ending coordinate of the BEDCoord
207+ * set end coordinate
208+ *
209+ * @param sto end coordinate (0-indexed, inclusive)
186210 */
187211 public void setStop (int sto ) {
188212 STOP = sto ;
189213 }
190214
191215 /**
192- * Returns the strand direction
193- * @return the strand direction (+/-)
216+ * get strand direction
217+ *
218+ * @return strand ("+"/"\-")
194219 */
195220 public String getDir () {
196221 return DIR ;
197222 }
198223
199224 /**
200- * Sets the strand direction
201- * @param di The strand direction (+/-)
225+ * set strand direction
226+ *
227+ * @param di strand ("+"/"\-")
202228 */
203229 public void setDir (String di ) {
204230 DIR = di ;
205231 }
206232
207233 /**
208- * Returns the name of the BEDCoord
209- * @return The name of the BEDCoord
234+ * get record name
235+ *
236+ * @return record name
210237 */
211238 public String getName () {
212239 return NAME ;
213240 }
214241
215242 /**
216- * Sets the name of the BEDCoord
217- * @param na The name of the BEDCoord
243+ * set record name
244+ * @param na record name
218245 */
219246 public void setName (String na ) {
220247 NAME = na ;
221248 }
222249
223250 /**
224- * Returns the score of the BEDCoord
225- * @return The score of the BEDCoord
251+ * get record score
252+ * @return record score
226253 */
227254 public double getScore () {
228255 return SCORE ;
229256 }
230257
231258 /**
232- * Sets the score of the BEDCoord
233- * @param sco The new score of the BEDCoord
259+ * set record score
260+ * @param sco record score
234261 */
235262 public void setScore (double sco ) {
236263 SCORE = sco ;
237264 }
238265
239266 /**
240- * Returns the different variables of a BEDCoord represented by a string
241- * @return The different variables of a BEDCoord represented by a string
267+ * format coordinate info in a BED-formatted string
268+ *
269+ * @return coordinate info in BED-format
242270 */
243271 public String toString () {
244272 String line = CHROM + "\t " + START + "\t " + STOP + "\t " + NAME + "\t " + SCORE + "\t " + DIR ;
245273 return line ;
246274 }
247-
275+
248276 /**
249277 * Creates a new comparator which compares BEDCoords based on their chromosomes
250278 */
@@ -257,7 +285,7 @@ public String toString() {
257285 */
258286 public int compare (BEDCoord node1 , BEDCoord node2 ) {
259287 return node1 .getChrom ().compareTo (node2 .getChrom ());
260- }
288+ }
261289 };
262290
263291 /**
@@ -278,7 +306,7 @@ public int compare(BEDCoord node1, BEDCoord node2) {
278306 else return 0 ;
279307 }
280308 };
281-
309+
282310 /**
283311 * Creates a new comparator which compares BEDCoords based the coordinates on their mid point
284312 */
@@ -297,7 +325,7 @@ public int compare(BEDCoord node1, BEDCoord node2) {
297325 else return 0 ;
298326 }
299327 };
300-
328+
301329 /**
302330 * Creates a new comparator which compares BEDCoords based the coordinates on their score
303331 */
0 commit comments