Fixing merge conflict
This commit is contained in:
commit
4501dce58d
|
|
@ -408,12 +408,12 @@ public class MathUtils {
|
||||||
return Math.sqrt(rms);
|
return Math.sqrt(rms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double rms(Collection<Double> l) {
|
public static double rms(Collection<Integer> l) {
|
||||||
if (l.size() == 0)
|
if (l.size() == 0)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
double rms = 0.0;
|
double rms = 0.0;
|
||||||
for (Double i : l)
|
for (int i : l)
|
||||||
rms += i*i;
|
rms += i*i;
|
||||||
rms /= l.size();
|
rms /= l.size();
|
||||||
return Math.sqrt(rms);
|
return Math.sqrt(rms);
|
||||||
|
|
|
||||||
|
|
@ -198,13 +198,15 @@ public class AlignmentUtils {
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the mismatches in the read within the given reference context.
|
/** Returns the number of mismatches in the pileup element within the given reference context.
|
||||||
*
|
*
|
||||||
* @param read the SAMRecord
|
* @param read the SAMRecord
|
||||||
* @param ref the reference context
|
* @param ref the reference context
|
||||||
* @return each base is represented by a bit in the BitSet. True for mismatch, false for ref
|
* @param maxMismatches the maximum number of surrounding mismatches we tolerate to consider a base good
|
||||||
|
* @param windowSize window size (on each side) to test
|
||||||
|
* @return a bitset representing which bases are good
|
||||||
*/
|
*/
|
||||||
public static BitSet mismatchesInRefWindow(SAMRecord read, ReferenceContext ref) {
|
public static BitSet mismatchesInRefWindow(SAMRecord read, ReferenceContext ref, int maxMismatches, int windowSize) {
|
||||||
// first determine the positions with mismatches
|
// first determine the positions with mismatches
|
||||||
int readLength = read.getReadLength();
|
int readLength = read.getReadLength();
|
||||||
BitSet mismatches = new BitSet(readLength);
|
BitSet mismatches = new BitSet(readLength);
|
||||||
|
|
@ -212,7 +214,7 @@ public class AlignmentUtils {
|
||||||
// it's possible we aren't starting at the beginning of a read,
|
// it's possible we aren't starting at the beginning of a read,
|
||||||
// and we don't need to look at any of the previous context outside our window
|
// and we don't need to look at any of the previous context outside our window
|
||||||
// (although we do need future context)
|
// (although we do need future context)
|
||||||
int readStartPos = read.getAlignmentStart();
|
int readStartPos = Math.max(read.getAlignmentStart(), ref.getLocus().getStart() - windowSize);
|
||||||
int currentReadPos = read.getAlignmentStart();
|
int currentReadPos = read.getAlignmentStart();
|
||||||
|
|
||||||
byte[] refBases = ref.getBases();
|
byte[] refBases = ref.getBases();
|
||||||
|
|
@ -263,22 +265,9 @@ public class AlignmentUtils {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mismatches;
|
|
||||||
}
|
|
||||||
/** Returns a BitSet showing what bases are good according to the criteria of maxMismatches in the window
|
|
||||||
*
|
|
||||||
* @param read the SAMRecord
|
|
||||||
* @param ref the reference context
|
|
||||||
* @param maxMismatches the maximum number of surrounding mismatches we tolerate to consider a base good
|
|
||||||
* @param windowSize window size (on each side) to test
|
|
||||||
* @return a bitset representing which bases are good
|
|
||||||
*/
|
|
||||||
public static BitSet mismatchesInRefWindow(SAMRecord read, ReferenceContext ref, int maxMismatches, int windowSize) {
|
|
||||||
int readLength = read.getReadLength();
|
|
||||||
|
|
||||||
// all bits are set to false by default
|
// all bits are set to false by default
|
||||||
BitSet result = new BitSet(readLength);
|
BitSet result = new BitSet(readLength);
|
||||||
BitSet mismatches = mismatchesInRefWindow(read, ref);
|
|
||||||
|
|
||||||
int currentPos = 0, leftPos = 0, rightPos;
|
int currentPos = 0, leftPos = 0, rightPos;
|
||||||
int mismatchCount = 0;
|
int mismatchCount = 0;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GATKSAMRecord extends BAMRecord {
|
public class GATKSAMRecord extends BAMRecord {
|
||||||
|
public static final String REDUCED_READ_QUALITY_TAG = "RR";
|
||||||
// the SAMRecord data we're caching
|
// the SAMRecord data we're caching
|
||||||
private String mReadString = null;
|
private String mReadString = null;
|
||||||
private GATKSAMReadGroupRecord mReadGroup = null;
|
private GATKSAMReadGroupRecord mReadGroup = null;
|
||||||
|
|
@ -151,7 +152,7 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
|
|
||||||
public byte[] getReducedReadCounts() {
|
public byte[] getReducedReadCounts() {
|
||||||
if ( ! retrievedReduceReadCounts ) {
|
if ( ! retrievedReduceReadCounts ) {
|
||||||
reducedReadCounts = getByteArrayAttribute(ReadUtils.REDUCED_READ_QUALITY_TAG);
|
reducedReadCounts = getByteArrayAttribute(REDUCED_READ_QUALITY_TAG);
|
||||||
retrievedReduceReadCounts = true;
|
retrievedReduceReadCounts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ public class ReadUtils {
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
public static final String REDUCED_READ_QUALITY_TAG = "RQ";
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// General utilities
|
// General utilities
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class ReadUtilsUnitTest extends BaseTest {
|
||||||
reducedRead = ArtificialSAMUtils.createArtificialRead(header, "reducedRead", 0, 1, BASES.length());
|
reducedRead = ArtificialSAMUtils.createArtificialRead(header, "reducedRead", 0, 1, BASES.length());
|
||||||
reducedRead.setReadBases(BASES.getBytes());
|
reducedRead.setReadBases(BASES.getBytes());
|
||||||
reducedRead.setBaseQualityString(QUALS);
|
reducedRead.setBaseQualityString(QUALS);
|
||||||
reducedRead.setAttribute(ReadUtils.REDUCED_READ_QUALITY_TAG, REDUCED_READ_COUNTS);
|
reducedRead.setAttribute(GATKSAMRecord.REDUCED_READ_QUALITY_TAG, REDUCED_READ_COUNTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testReadBasesAndQuals(SAMRecord read, int expectedStart, int expectedStop) {
|
private void testReadBasesAndQuals(SAMRecord read, int expectedStart, int expectedStop) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue