@@ -35,7 +35,7 @@ public PileupExtract(PileupParameters p, File b, Vector<BEDCoord> i, int current
3535 subsetsize = length ;
3636 }
3737
38- public void extract (BEDCoord read ) {
38+ public void extract (BEDCoord coord ) {
3939 double [] TAG_S1 = null ;
4040 double [] TAG_S2 = null ;
4141 int SHIFT = param .getShift ();
@@ -46,8 +46,8 @@ public void extract(BEDCoord read) {
4646 int MIDPOINT_ADJUST = 0 ;
4747 if (param .getRead () == 3 ) { MIDPOINT_ADJUST = 300 ; }
4848
49- int BEDSTART = (int )read .getStart ();
50- int BEDSTOP = (int )read .getStop ();
49+ int BEDSTART = (int )coord .getStart ();
50+ int BEDSTOP = (int )coord .getStop ();
5151
5252 //Correct Window Size for proper transformations
5353 int WINDOW = (BEDSTOP - BEDSTART ) + ((param .getBin () / 2 ) * 2 );
@@ -64,7 +64,7 @@ else if(param.getTrans() == 2) {
6464 if (STRAND == 0 ) TAG_S2 = new double [WINDOW ];
6565
6666 //SAMRecords are 1-based
67- CloseableIterator <SAMRecord > iter = inputSam .query (read .getChrom (), BEDSTART - QUERYWINDOW - SHIFT - MIDPOINT_ADJUST - 1 , BEDSTOP + QUERYWINDOW + SHIFT + MIDPOINT_ADJUST + 1 , false );
67+ CloseableIterator <SAMRecord > iter = inputSam .query (coord .getChrom (), BEDSTART - QUERYWINDOW - SHIFT - MIDPOINT_ADJUST - 1 , BEDSTOP + QUERYWINDOW + SHIFT + MIDPOINT_ADJUST + 1 , false );
6868 while (iter .hasNext ()) {
6969 //Create the record object
7070 //SAMRecord is 1-based
@@ -74,72 +74,72 @@ else if(param.getTrans() == 2) {
7474 if ((sr .getProperPairFlag () && param .getPErequire ()) || !param .getPErequire ()) { //Must either be properly paired if paired-end or don't care about requirement
7575 //Read 1 and want Read 1, Read 2 and want Read 2, want any read, Read 1 and want midpoint
7676 if ((sr .getFirstOfPairFlag () && param .getRead () == 0 ) || (!sr .getFirstOfPairFlag () && param .getRead () == 1 ) || param .getRead () == 2 || (sr .getFirstOfPairFlag () && param .getRead () == 3 )) {
77- int FivePrime = sr .getUnclippedStart () - 1 ;
77+ int mark = sr .getUnclippedStart () - 1 ;
7878 if (sr .getReadNegativeStrandFlag ()) {
79- FivePrime = sr .getUnclippedEnd () - 1 ;
80- FivePrime -= SHIFT ; //SHIFT DATA HERE IF NECCESSARY
81- } else { FivePrime += SHIFT ; }
79+ mark = sr .getUnclippedEnd () - 1 ;
80+ mark -= SHIFT ; //SHIFT DATA HERE IF NECCESSARY
81+ } else { mark += SHIFT ; }
8282
8383 if (sr .getProperPairFlag ()) { //prevent cases where non-properly paired Read1 gets to this point
8484 //Find midpoint if read flag == 3
8585 if (param .getRead () == 3 ) {
8686 if (sr .getInferredInsertSize ()>0 ) {
87- FivePrime = sr .getAlignmentStart () - 1 + (sr .getInferredInsertSize () / 2 );
87+ mark = sr .getAlignmentStart () - 1 + (sr .getInferredInsertSize () / 2 );
8888 } else if (sr .getInferredInsertSize ()<0 ) {
89- FivePrime = sr .getMateAlignmentStart () - 1 - (sr .getInferredInsertSize () / 2 );
89+ mark = sr .getMateAlignmentStart () - 1 - (sr .getInferredInsertSize () / 2 );
9090 } else {
9191 //Most aligners will flag records with an insert size of zero as improper pairs
9292 System .err .println ("This statement should never print (insert size=0 when finding midpoint in PileupExtract)" );
9393 continue ;
9494 }
9595 // Correction to ensure that even insert size mark reoriented for negative strands
96- if (sr .getInferredInsertSize () % 2 == 0 && read .getDir ().equals ("-" ) ) { FivePrime --; }
96+ if (sr .getInferredInsertSize () % 2 == 0 && coord .getDir ().equals ("-" ) ) { mark --; }
9797 }
9898 // Apply insert size filters
9999 if (Math .abs (sr .getInferredInsertSize ()) < param .getMinInsert () && param .getMinInsert () != -9999 ) { continue ; } //Test for MIN insert size cutoff here
100100 if (Math .abs (sr .getInferredInsertSize ()) > param .getMaxInsert () && param .getMaxInsert () != -9999 ) { continue ; } //Test for MAX insert size cutoff here
101101 } else if (param .getRead () == 3 ) { continue ; } // Make sure that midpoint pileup must come from properly paired read
102102
103103 //Adjust tag start to be within array reference
104- FivePrime -= (BEDSTART - QUERYWINDOW );
104+ mark -= (BEDSTART - QUERYWINDOW );
105105
106106 //Increment Final Array keeping track of pileup
107- if (FivePrime >= 0 && FivePrime < TAG_S1 .length ) {
107+ if (mark >= 0 && mark < TAG_S1 .length ) {
108108 if (STRAND == 0 ) {
109- if (!sr .getReadNegativeStrandFlag () && read .getDir ().equals ("-" )) { TAG_S2 [FivePrime ] += 1 ; }
110- else if (sr .getReadNegativeStrandFlag () && read .getDir ().equals ("+" )) { TAG_S2 [FivePrime ] += 1 ; }
111- else if (!sr .getReadNegativeStrandFlag () && read .getDir ().equals ("+" )) { TAG_S1 [FivePrime ] += 1 ; }
112- else if (sr .getReadNegativeStrandFlag () && read .getDir ().equals ("-" )) { TAG_S1 [FivePrime ] += 1 ;}
109+ if (!sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("-" )) { TAG_S2 [mark ] += 1 ; }
110+ else if (sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("+" )) { TAG_S2 [mark ] += 1 ; }
111+ else if (!sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("+" )) { TAG_S1 [mark ] += 1 ; }
112+ else if (sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("-" )) { TAG_S1 [mark ] += 1 ;}
113113 } else {
114- TAG_S1 [FivePrime ] += 1 ;
114+ TAG_S1 [mark ] += 1 ;
115115 }
116116 }
117117 }
118118 }
119119 } else if (param .getRead () == 0 || param .getRead () == 2 ) { //Also outputs if not paired-end since by default it is read-1
120- int FivePrime = sr .getUnclippedStart () - 1 ;
120+ int mark = sr .getUnclippedStart () - 1 ;
121121 if (sr .getReadNegativeStrandFlag ()) {
122- FivePrime = sr .getUnclippedEnd () - 1 ;
123- FivePrime -= SHIFT ; //SHIFT DATA HERE IF NECCESSARY
124- } else { FivePrime += SHIFT ; }
125- FivePrime -= (BEDSTART - QUERYWINDOW );
122+ mark = sr .getUnclippedEnd () - 1 ;
123+ mark -= SHIFT ; //SHIFT DATA HERE IF NECCESSARY
124+ } else { mark += SHIFT ; }
125+ mark -= (BEDSTART - QUERYWINDOW );
126126
127127 //Increment Final Array keeping track of pileup
128- if (FivePrime >= 0 && FivePrime < TAG_S1 .length ) {
128+ if (mark >= 0 && mark < TAG_S1 .length ) {
129129 if (STRAND == 0 ) {
130- if (!sr .getReadNegativeStrandFlag () && read .getDir ().equals ("-" )) { TAG_S2 [FivePrime ] += 1 ; }
131- else if (sr .getReadNegativeStrandFlag () && read .getDir ().equals ("+" )) { TAG_S2 [FivePrime ] += 1 ; }
132- else if (!sr .getReadNegativeStrandFlag () && read .getDir ().equals ("+" )) { TAG_S1 [FivePrime ] += 1 ; }
133- else if (sr .getReadNegativeStrandFlag () && read .getDir ().equals ("-" )) { TAG_S1 [FivePrime ] += 1 ;}
130+ if (!sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("-" )) { TAG_S2 [mark ] += 1 ; }
131+ else if (sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("+" )) { TAG_S2 [mark ] += 1 ; }
132+ else if (!sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("+" )) { TAG_S1 [mark ] += 1 ; }
133+ else if (sr .getReadNegativeStrandFlag () && coord .getDir ().equals ("-" )) { TAG_S1 [mark ] += 1 ;}
134134 } else {
135- TAG_S1 [FivePrime ] += 1 ;
135+ TAG_S1 [mark ] += 1 ;
136136 }
137137 }
138138 }
139139 }
140140 iter .close ();
141141
142- if (read .getDir ().equals ("-" )) {
142+ if (coord .getDir ().equals ("-" )) {
143143 TAG_S1 = ArrayUtilities .reverseArray (TAG_S1 );
144144 TAG_S2 = ArrayUtilities .reverseArray (TAG_S2 );
145145 }
@@ -176,7 +176,7 @@ else if(param.getTrans() == 2) {
176176 }
177177 }
178178
179- read .setFstrand (finalF );
180- read .setRstrand (finalR );
179+ coord .setFstrand (finalF );
180+ coord .setRstrand (finalR );
181181 }
182182}
0 commit comments