@@ -285,7 +285,7 @@ Map<Integer, Integer>, Integer, Double> parseSAM(Region region, String bam,
285285 processCigar :
286286 //Loop over CIGAR records
287287 for (int ci = 0 ; ci < cigar .numCigarElements (); ci ++) {
288- if (skipOverlappingReads (conf , record , dir , start , mateAlignmentStart )) {
288+ if (skipOverlappingReads (conf , record , position , dir , start , mateAlignmentStart )) {
289289 break ;
290290 }
291291 // Length of segment in CIGAR
@@ -318,7 +318,7 @@ Map<Integer, Integer>, Integer, Double> parseSAM(Region region, String bam,
318318 String saTagString = record .getStringAttribute (SAMTag .SA .name ());
319319
320320 if (m >= 20 && saTagString != null ) {
321- if (isReadChimericWithSA (record , saTagString , rlen , dir , conf , true )) {
321+ if (isReadChimericWithSA (record , position , saTagString , rlen , dir , conf , true )) {
322322 n += m ;
323323 offset = 0 ;
324324 // Had to reset the start due to softclipping adjustment
@@ -402,7 +402,7 @@ && isHasAndEquals(querySequence.charAt(m - 1), ref, start - 1)
402402 if (!conf .chimeric ) {
403403 String saTagString = record .getStringAttribute (SAMTag .SA .name ());
404404 if (m >= 20 && saTagString != null ) {
405- if (isReadChimericWithSA (record , saTagString , rlen ,
405+ if (isReadChimericWithSA (record , position , saTagString , rlen ,
406406 dir , conf , false )) {
407407 n += m ;
408408 offset = 0 ;
@@ -1087,7 +1087,7 @@ && isNotEquals('N', ref.get(start))) {
10871087 p ++;
10881088 }
10891089 // Skip read if it is overlap
1090- if (skipOverlappingReads (conf , record , dir , start , mateAlignmentStart )) {
1090+ if (skipOverlappingReads (conf , record , position , dir , start , mateAlignmentStart )) {
10911091 break processCigar ;
10921092 }
10931093 }
@@ -1269,7 +1269,7 @@ private static void addVariationForDeletion(Configuration conf,
12691269 }
12701270 }
12711271
1272- private static boolean isReadChimericWithSA (SAMRecord record , String saTagString , int rlen ,
1272+ private static boolean isReadChimericWithSA (SAMRecord record , int position , String saTagString , int rlen ,
12731273 boolean dir , Configuration conf , boolean is5Side ){
12741274 String [] saTagArray = saTagString .split ("," );
12751275 String saChromosome = saTagArray [0 ];
@@ -1285,12 +1285,12 @@ private static boolean isReadChimericWithSA(SAMRecord record, String saTagString
12851285
12861286 boolean isChimericWithSA = ((dir && saDirectionIsForward ) || (!dir && !saDirectionIsForward ))
12871287 && saChromosome .equals (record .getReferenceName ())
1288- && (abs (saPosition - record . getAlignmentStart () ) < 2 * rlen )
1288+ && (abs (saPosition - position ) < 2 * rlen )
12891289 && mm .find ();
12901290
12911291 if (conf .y && isChimericWithSA ) {
12921292 System .err .println (record .getReadName () + " " + record .getReferenceName ()
1293- + " " + record . getAlignmentStart () + " " + record .getMappingQuality ()
1293+ + " " + position + " " + record .getMappingQuality ()
12941294 + " " + record .getCigarString ()
12951295 + " is ignored as chimeric with SA: " +
12961296 saPosition + "," + saDirectionString + "," + saCigar );
@@ -1328,20 +1328,20 @@ private static void appendSegments(String querySequence, String queryQuality, Ci
13281328 }
13291329 }
13301330
1331- private static boolean skipOverlappingReads (Configuration conf , SAMRecord record , boolean dir , int start , int mateAlignmentStart ) {
1331+ private static boolean skipOverlappingReads (Configuration conf , SAMRecord record , int position , boolean dir , int start , int mateAlignmentStart ) {
13321332 if (conf .uniqueModeAlignmentEnabled && isPairedAndSameChromosome (record )
13331333 && !dir && start >= mateAlignmentStart ) {
13341334 return true ;
13351335 }
13361336 if (conf .uniqueModeSecondInPairEnabled && record .getSecondOfPairFlag () && isPairedAndSameChromosome (record )
1337- && isReadsOverlap (record , start , mateAlignmentStart )) {
1337+ && isReadsOverlap (record , start , position , mateAlignmentStart )) {
13381338 return true ;
13391339 }
13401340 return false ;
13411341 }
13421342
1343- private static boolean isReadsOverlap (SAMRecord record , int start , int mateAlignmentStart ){
1344- if (record . getAlignmentStart () >= mateAlignmentStart ) {
1343+ private static boolean isReadsOverlap (SAMRecord record , int start , int position , int mateAlignmentStart ){
1344+ if (position >= mateAlignmentStart ) {
13451345 return start >= mateAlignmentStart
13461346 && start <= (mateAlignmentStart + record .getCigar ().getReferenceLength () - 1 );
13471347 }
0 commit comments