Minor changes to oneoff walkers. PlinkRod altered but still commented.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2808 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
chartl 2010-02-08 18:49:56 +00:00
parent 21369869b7
commit 935e76daa1
5 changed files with 1010 additions and 937 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,8 @@ import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.BaseUtils;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random; import java.util.Random;
/** /**
@ -17,7 +19,7 @@ import java.util.Random;
* *
* @author Kiran Garimella * @author Kiran Garimella
*/ */
public class ReadErrorRateWalker extends ReadWalker<boolean[], int[]> { public class ReadErrorRateWalker extends ReadWalker<boolean[], ReadErrorRateCollection> {
@Argument(fullName="printVisualHits", shortName="v", doc="print visual hits", required=false) public boolean printVisualHits = false; @Argument(fullName="printVisualHits", shortName="v", doc="print visual hits", required=false) public boolean printVisualHits = false;
@Argument(fullName="useNextBestBase", shortName="nb", doc="use next best base", required=false) public boolean useNextBestBase = false; @Argument(fullName="useNextBestBase", shortName="nb", doc="use next best base", required=false) public boolean useNextBestBase = false;
@Argument(fullName="useNonNextBestBase",shortName="nnb",doc="use nonnext best base",required=false) public boolean useNonNextBestBase = false; @Argument(fullName="useNonNextBestBase",shortName="nnb",doc="use nonnext best base",required=false) public boolean useNonNextBestBase = false;
@ -134,38 +136,80 @@ public class ReadErrorRateWalker extends ReadWalker<boolean[], int[]> {
* *
* @return null * @return null
*/ */
public int[] reduceInit() { public ReadErrorRateCollection reduceInit() {
return null; return new ReadErrorRateCollection();
} }
/** /**
* Summarize the error rate data. * Summarize the error rate data.
* *
* @param value the read mismatch array * @param value the read mismatch array
* @param sum the summed mismatch array * @param collection the summed mismatch array
* @return the summed mismatch array with the new read mismatch array added * @return the summed mismatch array with the new read mismatch array added
*/ */
public int[] reduce(boolean[] value, int[] sum) { public ReadErrorRateCollection reduce(boolean[] value, ReadErrorRateCollection collection) {
if (sum == null) {
sum = new int[value.length];
}
for (int cycle = 0; cycle < value.length; cycle++) { collection.update(value);
sum[cycle] += (value[cycle] ? 1 : 0);
}
return sum; return collection;
} }
/** /**
* We've processed all the reads. Emit the final, normalized error rate data. * We've processed all the reads. Emit the final, normalized error rate data.
* *
* @param sum the summed mismatch array * @param collection the summed mismatch arrays
*/ */
public void onTraversalDone(int[] sum) { public void onTraversalDone(ReadErrorRateCollection collection) {
for (int cycle = 0; cycle < sum.length - 1; cycle++) {
double errorrate = ((double) sum[cycle])/((double) sum[sum.length - 1]); out.print(collection.toString());
out.println("[ERROR_RATE] " + cycle + " " + errorrate);
}
} }
} }
class ReadErrorRateCollection {
private HashMap<Integer,int[]> readsByReadLength;
public ReadErrorRateCollection() {
readsByReadLength = new HashMap<Integer, int[]>();
}
public void update(boolean[] mismatchArray) {
if ( ! readsByReadLength.containsKey(mismatchArray.length) ) {
readsByReadLength.put(mismatchArray.length, zeroArray(mismatchArray.length));
}
updateErrorCounts(readsByReadLength.get(mismatchArray.length), mismatchArray);
}
public String toString() {
StringBuilder builder = new StringBuilder();
for ( int length : readsByReadLength.keySet() ) {
for ( int cycle = 0; cycle < length-1; cycle++) {
int[] counts = readsByReadLength.get(length);
builder.append(length);
builder.append("\t");
builder.append(cycle);
builder.append("\t");
builder.append( ( ( double ) counts[cycle] / ( (double) counts[length-1])));
builder.append("\n");
}
}
return builder.toString();
}
private static int[] zeroArray( int length ) {
int[] array = new int[length];
for ( int ii = 0; ii < length; ii ++ ) {
array[ii] = 0;
}
return array;
}
public static void updateErrorCounts(int[] sum, boolean[] value) {
for (int cycle = 0; cycle < value.length; cycle++) {
sum[cycle] += (value[cycle] ? 1 : 0);
}
}
}

View File

@ -22,11 +22,6 @@ class MultiSampleConcordanceSet {
private long truthSitesFilteredOut; private long truthSitesFilteredOut;
private int genotypeQuality; private int genotypeQuality;
private int truePositiveLoci;
private int trueNegativeLoci;
private int falsePositiveLoci;
private int falseNegativeLoci;
public MultiSampleConcordanceSet(int minDepth, boolean assumeRef, int genotypeQuality) { public MultiSampleConcordanceSet(int minDepth, boolean assumeRef, int genotypeQuality) {
concordanceSet = new HashSet<VCFConcordanceCalculator>(); concordanceSet = new HashSet<VCFConcordanceCalculator>();
truthOnlySites = 0l; truthOnlySites = 0l;

View File

@ -58,35 +58,58 @@ public class MultiSampleConcordanceWalker extends RodWalker< LocusConcordanceInf
ReferenceOrderedDatum truthData = tracker.lookup("truth", null); ReferenceOrderedDatum truthData = tracker.lookup("truth", null);
ReferenceOrderedDatum variantData = tracker.lookup("variants",null); ReferenceOrderedDatum variantData = tracker.lookup("variants",null);
LocusConcordanceInfo concordance; LocusConcordanceInfo concordance;
if ( truthData == null && variantData == null) { if ( truthData == null && variantData == null) {
concordance = null; concordance = null;
} else if ( truthData == null ) { } else if ( truthData == null ) {
// not in the truth set // not in the truth set
if ( ( (RodVCF) variantData ).isFiltered() ) { if ( ( (RodVCF) variantData ).isFiltered() ) {
concordance = null; concordance = null;
} else { } else {
concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.VARIANT_SET,null, ( (RodVCF) variantData ).getRecord(),ref); concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.VARIANT_SET,null, ( (RodVCF) variantData ).getRecord(),ref);
} }
} else if ( variantData == null ) { } else if ( variantData == null ) {
// not in the variant set // not in the variant set
if ( ( (RodVCF) truthData).isFiltered() ) { if ( ( (RodVCF) truthData).isFiltered() ) {
concordance = null; concordance = null;
} else { } else {
concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.TRUTH_SET,( (RodVCF) truthData).getRecord(),null,ref); concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.TRUTH_SET,( (RodVCF) truthData).getRecord(),null,ref);
} }
} else { } else {
// in both // in both
// check for filtering // check for filtering
boolean truth_filter = ((RodVCF) truthData).isFiltered(); boolean truth_filter = ((RodVCF) truthData).isFiltered();
boolean call_filter = ((RodVCF) variantData).isFiltered(); boolean call_filter = ((RodVCF) variantData).isFiltered();
if ( truth_filter && call_filter ) { if ( truth_filter && call_filter ) {
concordance = null; concordance = null;
} else if ( truth_filter ) { } else if ( truth_filter ) {
concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.VARIANT_SET,null, ( (RodVCF) variantData ).getRecord(),ref); concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.VARIANT_SET,null, ( (RodVCF) variantData ).getRecord(),ref);
} else if ( call_filter ) { } else if ( call_filter ) {
concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.TRUTH_SET_VARIANT_FILTERED,( (RodVCF) truthData).getRecord(), null ,ref); concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.TRUTH_SET_VARIANT_FILTERED,( (RodVCF) truthData).getRecord(), null ,ref);
} else { } else {
concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.BOTH_SETS,( (RodVCF) truthData).getRecord(),( (RodVCF) variantData).getRecord(),ref); concordance = new LocusConcordanceInfo(LocusConcordanceInfo.ConcordanceType.BOTH_SETS,( (RodVCF) truthData).getRecord(),( (RodVCF) variantData).getRecord(),ref);
} }
} }

View File

@ -1,243 +1,247 @@
//package org.broadinstitute.sting.gatk.refdata; package org.broadinstitute.sting.gatk.refdata;
// /*
//import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.BaseTest;
//import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile; import org.broadinstitute.sting.oneoffprojects.variantcontext.Allele;
//import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.oneoffprojects.variantcontext.Genotype;
//import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile;
//import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException;
//import org.junit.BeforeClass; import org.broadinstitute.sting.utils.GenomeLocParser;
//import org.junit.Test; import org.broadinstitute.sting.utils.GenomeLoc;
//import org.junit.Assert; import org.junit.BeforeClass;
// import org.junit.Test;
//import java.io.File; import org.junit.Assert;
//import java.io.FileNotFoundException;
//import java.io.BufferedReader; import java.io.File;
//import java.io.FileReader; import java.io.FileNotFoundException;
//import java.util.*; import java.io.BufferedReader;
// import java.io.FileReader;
///** import java.util.*;
// * Created by IntelliJ IDEA.
// * User: Ghost /**
// * Date: Jan 22, 2010 * Created by IntelliJ IDEA.
// * Time: 11:27:33 PM * User: chartl
// * To change this template use File | Settings | File Templates. * Date: Jan 22, 2010
// */ * Time: 11:27:33 PM
//public class PlinkRodTest extends BaseTest { * To change this template use File | Settings | File Templates.
// private static IndexedFastaSequenceFile seq; *
// public class PlinkRodTest extends BaseTest {
// @BeforeClass // todo :: get the isIndel() isInsertion() and isDeletion() tests working again -- this may require new
// public static void beforeTests() { // todo :: methods in the objects themselves
// try { private static IndexedFastaSequenceFile seq;
// seq = new IndexedFastaSequenceFile(new File(oneKGLocation + "reference/human_b36_both.fasta"));
// } catch (FileNotFoundException e) { @BeforeClass
// throw new StingException("unable to load the sequence dictionary"); public static void beforeTests() {
// } try {
// GenomeLocParser.setupRefContigOrdering(seq); seq = new IndexedFastaSequenceFile(new File(oneKGLocation + "reference/human_b36_both.fasta"));
// } catch (FileNotFoundException e) {
// } throw new StingException("unable to load the sequence dictionary");
// }
// public BufferedReader openFile(String filename) { GenomeLocParser.setupRefContigOrdering(seq);
// try {
// return new BufferedReader(new FileReader(filename)); }
// } catch (FileNotFoundException e) {
// throw new StingException("Couldn't open file " + filename); public BufferedReader openFile(String filename) {
// } try {
// return new BufferedReader(new FileReader(filename));
// } } catch (FileNotFoundException e) {
// throw new StingException("Couldn't open file " + filename);
// @Test }
// public void testStandardPedFile() {
// PlinkRod rod = new PlinkRod("test"); }
// try {
// rod.initialize( new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/standard_plink_test.ped") ); @Test
// } catch ( FileNotFoundException e ) { public void testStandardPedFile() {
// throw new StingException("test file for testStandardPedFile() does not exist",e); PlinkRod rod = new PlinkRod("test");
// } try {
// rod.initialize( new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/standard_plink_test.ped") );
// // test that the sample names are correct } catch ( FileNotFoundException e ) {
// throw new StingException("test file for testStandardPedFile() does not exist",e);
// List<String> rodNames = rod.getVariantSampleNames(); }
// List<String> expectedNames = Arrays.asList("NA12887","NAMELY","COWBA");
// // test that the sample names are correct
// Assert.assertEquals("That there are as many samples in the rod as in the expected list",expectedNames.size(),rodNames.size());
// List<String> rodNames = rod.getVariantSampleNames();
// boolean namesCorrect = true; List<String> expectedNames = Arrays.asList("NA12887","NAMELY","COWBA");
// for ( int i = 0; i < expectedNames.size(); i++ ) {
// namesCorrect = namesCorrect && ( rodNames.get(i).equals(expectedNames.get(i)) ); Assert.assertEquals("That there are as many samples in the rod as in the expected list",expectedNames.size(),rodNames.size());
// }
// boolean namesCorrect = true;
// Assert.assertTrue("That the names are correct and in the proper order",namesCorrect); for ( int i = 0; i < expectedNames.size(); i++ ) {
// namesCorrect = namesCorrect && ( rodNames.get(i).equals(expectedNames.get(i)) );
// // test that rod can be iterated over }
//
// ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>(); Assert.assertTrue("That the names are correct and in the proper order",namesCorrect);
// ArrayList<ArrayList<String>> sampleNamesInRod = new ArrayList<ArrayList<String>>();
// ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>(); // test that rod can be iterated over
// do {
// genotypesInRod.add(rod.getGenotypes()); ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>();
// sampleNamesInRod.add(rod.getVariantSampleNames()); ArrayList<ArrayList<String>> sampleNamesInRod = new ArrayList<ArrayList<String>>();
// lociInRod.add(rod.getLocation()); ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>();
// } while ( rod.parseLine(null,null) ); do {
// genotypesInRod.add(rod.getGenotypes());
// Assert.assertEquals("That there are three SNPs in the ROD",3,genotypesInRod.size()); sampleNamesInRod.add(rod.getVariantSampleNames());
// lociInRod.add(rod.getLocation());
// ArrayList<Genotype> snp1 = genotypesInRod.get(0); } while ( rod.parseLine(null,null) );
// ArrayList<Genotype> snp3 = genotypesInRod.get(2);
// Assert.assertEquals("That there are three SNPs in the ROD",3,genotypesInRod.size());
// Assert.assertEquals("That there are three Genotypes in SNP 1",3,snp1.size());
// Assert.assertEquals("That there are three samples in SNP 2", 3, sampleNamesInRod.get(1).size()); ArrayList<Genotype> snp1 = genotypesInRod.get(0);
// Assert.assertEquals("That there are three Genotypes in SNP 3",3,snp3.size()); ArrayList<Genotype> snp3 = genotypesInRod.get(2);
//
// Assert.assertEquals("That there are three Genotypes in SNP 1",3,snp1.size());
// List<Allele> snp1_individual3_alleles = snp1.get(2).getAlleles(); Assert.assertEquals("That there are three samples in SNP 2", 3, sampleNamesInRod.get(1).size());
// List<Allele> snp3_individual2_alleles = snp3.get(1).getAlleles(); Assert.assertEquals("That there are three Genotypes in SNP 3",3,snp3.size());
//
// String alleleStr1 = snp1_individual3_alleles.get(0).getBases()+snp1_individual3_alleles.get(1).getBases();
// String alleleStr2 = snp3_individual2_alleles.get(0).getBases()+snp3_individual2_alleles.get(1).getBases(); List<Allele> snp1_individual3_alleles = snp1.get(2).getAlleles();
// List<Allele> snp3_individual2_alleles = snp3.get(1).getAlleles();
// Assert.assertEquals("That the third genotype of snp 1 is correctly no-call","00",alleleStr1);
// Assert.assertEquals("That the second genotype of snp 3 is correctly G G","GG",alleleStr2); String alleleStr1 = new String(snp1_individual3_alleles.get(0).getBases())+new String(snp1_individual3_alleles.get(1).getBases());
// String alleleStr2 = new String(snp3_individual2_alleles.get(0).getBases())+new String(snp3_individual2_alleles.get(1).getBases());
// boolean name2isSame = true;
// Assert.assertEquals("That the third genotype of snp 1 is correctly no-call","00",alleleStr1);
// for ( ArrayList<String> names : sampleNamesInRod ) { Assert.assertEquals("That the second genotype of snp 3 is correctly G G","GG",alleleStr2);
// name2isSame = name2isSame && names.get(1).equals("NAMELY");
// } boolean name2isSame = true;
//
// Assert.assertTrue("That the second name of all the genotypes is the same and is correct",name2isSame); for ( ArrayList<String> names : sampleNamesInRod ) {
// name2isSame = name2isSame && names.get(1).equals("NAMELY");
// // test that the loci are correctly parsed and in order }
//
// List<String> expectedLoci = Arrays.asList("1:123456","2:13274","3:11111"); Assert.assertTrue("That the second name of all the genotypes is the same and is correct",name2isSame);
// boolean lociCorrect = true;
// for ( int i = 0; i < 3; i ++ ) { // test that the loci are correctly parsed and in order
// lociCorrect = lociCorrect && lociInRod.get(i).toString().equals(expectedLoci.get(i));
// } List<String> expectedLoci = Arrays.asList("1:123456","2:13274","3:11111");
// } boolean lociCorrect = true;
// for ( int i = 0; i < 3; i ++ ) {
// @Test lociCorrect = lociCorrect && lociInRod.get(i).toString().equals(expectedLoci.get(i));
// public void testStandardPedFileWithIndels() { }
// PlinkRod rod = new PlinkRod("test"); }
// try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/standard_plink_with_indels.ped") ); @Test
// } catch ( FileNotFoundException e) { public void testStandardPedFileWithIndels() {
// throw new StingException("Test file for testStandardPedFileWithIndels() could not be found", e); PlinkRod rod = new PlinkRod("test");
// } try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/standard_plink_with_indels.ped") );
// // Iterate through the rod } catch ( FileNotFoundException e) {
// throw new StingException("Test file for testStandardPedFileWithIndels() could not be found", e);
// List<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>(); }
// ArrayList<ArrayList<String>> sampleNamesInRod = new ArrayList<ArrayList<String>>();
// ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>(); // Iterate through the rod
// ArrayList<Boolean> snpSites = new ArrayList<Boolean>();
// do { List<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>();
// genotypesInRod.add(rod.getGenotypes()); ArrayList<ArrayList<String>> sampleNamesInRod = new ArrayList<ArrayList<String>>();
// sampleNamesInRod.add(rod.getVariantSampleNames()); ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>();
// lociInRod.add(rod.getLocation()); ArrayList<Boolean> snpSites = new ArrayList<Boolean>();
// snpSites.add(rod.variantIsSNP()); do {
// } while ( rod.parseLine(null,null) ); genotypesInRod.add(rod.getGenotypes());
// sampleNamesInRod.add(rod.getVariantSampleNames());
// boolean snpOrder = true; lociInRod.add(rod.getLocation());
// List<Boolean> expectedOrder = Arrays.asList(true,false,true,false); snpSites.add(rod.variantIsSNP());
// for ( int i = 0; i < 4; i ++ ) { } while ( rod.parseLine(null,null) );
// snpOrder = snpOrder && ( expectedOrder.get(i) == snpSites.get(i) );
// } boolean snpOrder = true;
// List<Boolean> expectedOrder = Arrays.asList(true,false,true,false);
// Assert.assertTrue("That the variant type order is as expected", snpOrder); for ( int i = 0; i < 4; i ++ ) {
// Assert.assertTrue("That the second genotype of second variant is not a point mutation", ! genotypesInRod.get(1).get(1).isPointGenotype() ); snpOrder = snpOrder && ( expectedOrder.get(i) == snpSites.get(i) );
// Assert.assertTrue("That the second genotype of fourth variant is not a point mutation", ! genotypesInRod.get(3).get(1).isPointGenotype() ); }
// Assert.assertTrue("That the second genotype of fourth variant is homozygous", genotypesInRod.get(3).get(1).isHom());
// Assert.assertTrue("That the fourth genotype of fourth variant is heterozygous",genotypesInRod.get(3).get(3).isHet()); Assert.assertTrue("That the variant type order is as expected", snpOrder);
// Assert.assertEquals("That the reference deletion genotype has the correct string", "ATTTAT",genotypesInRod.get(3).get(2).getAlleles().get(0).getBases()); // Assert.assertTrue("That the second genotype of second variant is not a point mutation", ! genotypesInRod.get(1).get(1). );
// Assert.assertEquals("That the insertion bases are correct","CTC",genotypesInRod.get(1).get(2).getAlleles().get(0).getBases()); // Assert.assertTrue("That the second genotype of fourth variant is not a point mutation", ! genotypesInRod.get(3).get(1).isPointGenotype() );
// Assert.assertEquals("That the snp bases are correct","GC",genotypesInRod.get(2).get(2).getAlleles().get(0).getBases()+genotypesInRod.get(2).get(2).getAlleles().get(1).getBases()); Assert.assertTrue("That the second genotype of fourth variant is homozygous", genotypesInRod.get(3).get(1).isHom());
// } Assert.assertTrue("That the fourth genotype of fourth variant is heterozygous",genotypesInRod.get(3).get(3).isHet());
// Assert.assertEquals("That the reference deletion genotype has the correct string", "ATTTAT",genotypesInRod.get(3).get(2).getAlleles().get(0).getBases());
// @Test Assert.assertEquals("That the insertion bases are correct","CTC",genotypesInRod.get(1).get(2).getAlleles().get(0).getBases());
// public void testBinaryPedFileNoIndels() { Assert.assertEquals("That the snp bases are correct","GC",new String(genotypesInRod.get(2).get(2).getAlleles().get(0).getBases())+new String(genotypesInRod.get(2).get(2).getAlleles().get(1).getBases()));
// PlinkRod rod = new PlinkRod("binaryTest1"); }
// try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/binary_noindel_test.bed")); @Test
// } catch (FileNotFoundException e) { public void testBinaryPedFileNoIndels() {
// throw new StingException("Test file for testBinaryPedFileNoIndels() could not be found",e); PlinkRod rod = new PlinkRod("binaryTest1");
// } try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/binary_noindel_test.bed"));
// // iterate through the ROD and get stuff } catch (FileNotFoundException e) {
// ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>(); throw new StingException("Test file for testBinaryPedFileNoIndels() could not be found",e);
// ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>(); }
// ArrayList<ArrayList<String>> samplesInRod = new ArrayList<ArrayList<String>>();
// // iterate through the ROD and get stuff
// do { ArrayList<GenomeLoc> lociInRod = new ArrayList<GenomeLoc>();
// lociInRod.add(rod.getLocation()); ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>();
// genotypesInRod.add(rod.getGenotypes()); ArrayList<ArrayList<String>> samplesInRod = new ArrayList<ArrayList<String>>();
// samplesInRod.add(rod.getVariantSampleNames());
// } while ( rod.parseLine(null,null) ); do {
// lociInRod.add(rod.getLocation());
// List<String> expecLoc = Arrays.asList("1:123456","1:14327877","2:22074511","3:134787","3:178678","4:829645","4:5234132","12:1268713"); genotypesInRod.add(rod.getGenotypes());
// samplesInRod.add(rod.getVariantSampleNames());
// for ( int i = 0; i < expecLoc.size(); i ++ ) { } while ( rod.parseLine(null,null) );
// Assert.assertEquals("That locus "+(i+1)+" in the rod is correct", expecLoc.get(i), lociInRod.get(i).toString());
// } List<String> expecLoc = Arrays.asList("1:123456","1:14327877","2:22074511","3:134787","3:178678","4:829645","4:5234132","12:1268713");
//
// List<String> expecAlleles = Arrays.asList("AA","AA","AA","GG","GG","GG","AA","TA","TT","CC","CC","GC","TC","CC","TT", for ( int i = 0; i < expecLoc.size(); i ++ ) {
// "GG","GG","AG","TT","CC","CT","TG","GG","GG"); Assert.assertEquals("That locus "+(i+1)+" in the rod is correct", expecLoc.get(i), lociInRod.get(i).toString());
// List<Boolean> expecHet = Arrays.asList(false,false,false,false,false,false,false,true,false,false,false,true,true,false, }
// false,false,false,true,false,false,true,true,false,false);
// List<String> expecName = Arrays.asList("NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000", List<String> expecAlleles = Arrays.asList("AA","AA","AA","GG","GG","GG","AA","TA","TT","CC","CC","GC","TC","CC","TT",
// "NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000", "GG","GG","AG","TT","CC","CT","TG","GG","GG");
// "NA12878","NA12890","NA07000"); List<Boolean> expecHet = Arrays.asList(false,false,false,false,false,false,false,true,false,false,false,true,true,false,
// int snpNo = 1; false,false,false,true,false,false,true,true,false,false);
// int indiv = 1; List<String> expecName = Arrays.asList("NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000",
// int alleleOffset = 0; "NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000","NA12878","NA12890","NA07000",
// for ( ArrayList<Genotype> snp : genotypesInRod ) { "NA12878","NA12890","NA07000");
// for ( Genotype gen : snp ) { int snpNo = 1;
// String alStr = gen.getAlleles().get(0).getBases()+gen.getAlleles().get(1).getBases(); int indiv = 1;
// Assert.assertEquals("That the allele of person "+indiv+" for snp "+snpNo+" is correct "+ int alleleOffset = 0;
// "(allele offset "+alleleOffset+")", expecAlleles.get(alleleOffset),alStr); for ( ArrayList<Genotype> snp : genotypesInRod ) {
// Assert.assertEquals("That the genotype of person "+indiv+" for snp "+snpNo+" is properly set", expecHet.get(alleleOffset),gen.isHet()); for ( Genotype gen : snp ) {
// Assert.assertEquals("That the name of person "+indiv+" for snp "+snpNo+" is correct", expecName.get(alleleOffset),samplesInRod.get(snpNo-1).get(indiv-1)); String alStr = new String(gen.getAlleles().get(0).getBases())+new String(gen.getAlleles().get(1).getBases());
// indiv++; Assert.assertEquals("That the allele of person "+indiv+" for snp "+snpNo+" is correct "+
// alleleOffset++; "(allele offset "+alleleOffset+")", expecAlleles.get(alleleOffset),alStr);
// } Assert.assertEquals("That the genotype of person "+indiv+" for snp "+snpNo+" is properly set", expecHet.get(alleleOffset),gen.isHet());
// indiv = 1; Assert.assertEquals("That the name of person "+indiv+" for snp "+snpNo+" is correct", expecName.get(alleleOffset),samplesInRod.get(snpNo-1).get(indiv-1));
// snpNo++; indiv++;
// } alleleOffset++;
// } }
// indiv = 1;
// @Test snpNo++;
// public void testIndelBinary() { }
// PlinkRod rod = new PlinkRod("binaryTest2"); }
// try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/binary_indel_test.bed")); @Test
// } catch (FileNotFoundException e) { public void testIndelBinary() {
// throw new StingException("Test file for testBinaryPedFileNoIndels() could not be found",e); PlinkRod rod = new PlinkRod("binaryTest2");
// } try {
// rod.initialize(new File("/humgen/gsa-hpprojects/GATK/data/Validation_Data/test/plink_rod_test/binary_indel_test.bed"));
// ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>(); } catch (FileNotFoundException e) {
// do { throw new StingException("Test file for testBinaryPedFileNoIndels() could not be found",e);
// genotypesInRod.add(rod.getGenotypes()); }
// } while ( rod.parseLine(null,null) );
// ArrayList<ArrayList<Genotype>> genotypesInRod = new ArrayList<ArrayList<Genotype>>();
// List<String> expecAlleles = Arrays.asList("ACCA","","ACCAACCA","GGGG","GG","","AA","TA","00","","CCTCCT","CCT", do {
// "TC","CC","TT","GG","GG","AG","","CTTGCTTG","CTTG","TG","GG","GG"); genotypesInRod.add(rod.getGenotypes());
// List<Boolean> expecDeletion = Arrays.asList(false,false,false,false,false,false,false,false,false,true,false,true, } while ( rod.parseLine(null,null) );
// false,false,false,false,false,false,true,false,true,false,false,false);
// List<Boolean> expecInsertion = Arrays.asList(true,false,true,true,true,false,false,false,false,false,false,false, List<String> expecAlleles = Arrays.asList("ACCA","","ACCAACCA","GGGG","GG","","AA","TA","00","","CCTCCT","CCT",
// false,false,false,false,false,false,false,false,false,false,false,false); "TC","CC","TT","GG","GG","AG","","CTTGCTTG","CTTG","TG","GG","GG");
// List<Boolean> expecDeletion = Arrays.asList(false,false,false,false,false,false,false,false,false,true,false,true,
// int al = 0; false,false,false,false,false,false,true,false,true,false,false,false);
// for ( ArrayList<Genotype> snp : genotypesInRod ) { List<Boolean> expecInsertion = Arrays.asList(true,false,true,true,true,false,false,false,false,false,false,false,
// for ( Genotype gen : snp ) { false,false,false,false,false,false,false,false,false,false,false,false);
// String alStr = gen.getAlleles().get(0).getBases()+gen.getAlleles().get(1).getBases();
// Allele firstAl = gen.getAlleles().get(0); int al = 0;
// Allele secondAl = gen.getAlleles().get(1); for ( ArrayList<Genotype> snp : genotypesInRod ) {
// boolean isInsertion = ( firstAl.getType() == Allele.AlleleType.INSERTION || secondAl.getType() == Allele.AlleleType.INSERTION ); for ( Genotype gen : snp ) {
// boolean isDeletion = ( firstAl.getType() == Allele.AlleleType.DELETION || secondAl.getType() == Allele.AlleleType.DELETION ); String alStr = new String(gen.getAlleles().get(0).getBases())+new String(gen.getAlleles().get(1).getBases());
// Assert.assertEquals("That the indel file has the correct alleles for genotype "+al,expecAlleles.get(al), alStr); Allele firstAl = gen.getAlleles().get(0);
// Assert.assertEquals("That the insertion property of genotype "+al+" is correct",expecInsertion.get(al),isInsertion); Allele secondAl = gen.getAlleles().get(1);
// Assert.assertEquals("That the deletion property of genotype "+al+" is correct", expecDeletion.get(al), isDeletion); // boolean isInsertion = ( firstAl.getType() == Allele.AlleleType.INSERTION || secondAl.getType() == Allele.AlleleType.INSERTION );
// al++; // boolean isDeletion = ( firstAl.getType() == Allele.AlleleType.DELETION || secondAl.getType() == Allele.AlleleType.DELETION );
// } Assert.assertEquals("That the indel file has the correct alleles for genotype "+al,expecAlleles.get(al), alStr);
// } // Assert.assertEquals("That the insertion property of genotype "+al+" is correct",expecInsertion.get(al),isInsertion);
// } // Assert.assertEquals("That the deletion property of genotype "+al+" is correct", expecDeletion.get(al), isDeletion);
//} al++;
}
}
}
}*/