@DataProvider(name = "ReadAlignedToRefData")
public Object[][] makeReadAlignedToRefData() {
List<Object[]> tests = new ArrayList<Object[]>();
final String hapBases = "ACTGAAGGTTCC";
final Haplotype allM = makeHaplotype(hapBases, hapBases.length() + "M");
// make sure we get back a cigar of the right length
for ( int i = -1; i < hapBases.length(); i++ ) {
final GATKSAMRecord read = makeRead(hapBases);
if ( i != -1 ) read.getReadBases()[i] = (byte)'A';
tests.add(new Object[]{read, allM, 10, 10, allM.getCigar().toString()});
}
// make sure insertions at the front are correctly handled
for ( int padFront = 1; padFront < 10; padFront++ ) {
final GATKSAMRecord read = makeRead(Utils.dupString("N", padFront) + hapBases);
tests.add(new Object[]{read, allM, 10, 10, padFront + "I" + allM.getCigar().toString()});
}
// make sure insertions at the back are correctly handled
for ( int padBack = 1; padBack < 10; padBack++ ) {
final GATKSAMRecord read = makeRead(hapBases + Utils.dupString("N", padBack));
tests.add(new Object[]{read, allM, 10, 10, allM.getCigar().toString() + padBack + "I"});
}
// make sure refStart and hapStart are respected
for ( int refStart = 1; refStart < 10; refStart++ ) {
for ( int hapStart = refStart; hapStart < 10 + refStart; hapStart++ ) {
final Haplotype hap = new Haplotype(allM.getBases());
hap.setCigar(allM.getCigar());
hap.setAlignmentStartHapwrtRef(hapStart);
final GATKSAMRecord read = makeRead(new String(hap.getBases()));
tests.add(new Object[]{read, hap, refStart, refStart + hapStart, allM.getCigar().toString()});
}
}
// example case of bad alignment because SW doesn't necessarily left-align indels
{
final String hap = "ACTGTGGGTTCCTCTTATTTTATTTCTACATCAATGTTCATATTTAACTTATTATTTTATCTTATTTTTAAATTTCTTTTATGTTGAGCCTTGATGAAAGCCATAGGTTCTCTCATATAATTGTATGTGTATGTATGTATATGTACATAATATATACATATATGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTGTATTACATAATATATACATATATGTATATATTATGTATATGTACATAATATATACATATATG";
final String hapCigar = "399M";
final String readBases = "ATGTACATAATATATACATATATGTATATGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTACATAATATATACGTATATGTATGTGTATGTGTATTACATAATATATACATATATGTATATATTATGTATATGTACATAATAT";
final GATKSAMRecord read = makeRead(readBases);
final int refStart = 10130100;
final int hapStart = 500;
final String badCigar = "31M6D211M";
final String goodCigar = "28M6D214M";
final Haplotype badHap = new Haplotype(hap.getBytes());
badHap.setCigar(TextCigarCodec.getSingleton().decode(hapCigar));
badHap.setAlignmentStartHapwrtRef(hapStart);
final int expectedPos = 10130740;
tests.add(new Object[]{read, badHap, refStart, expectedPos, goodCigar});
}