* @param posChromos Chromosomes for which all values are positive
* @param emptyChromos Chromosomes which have no data
* @throws Exception
*/
public void tstCHR_ALL(String genPath, String wigPath, String tdfPath, boolean expHaveChrAll, String[] posChromos, String[] emptyChromos) throws Exception{
Genome genome = null;
try {
genome = GenomeManager.getInstance().loadGenome(genPath, null);
} catch (IOException e) {
e.printStackTrace();
}
Assume.assumeTrue(genome != null);
WiggleDataset ds = (new WiggleParser(new ResourceLocator(wigPath), genome)).parse();
DatasetDataSource wigSource = new DatasetDataSource(wigPath, ds, genome);
TDFReader tdfReader = TDFReader.getReader(tdfPath);
TDFDataSource tdfSource = new TDFDataSource(tdfReader, 0, tdfPath, genome);
//We can't test for exact equality, so we just look for errors
List<LocusScore> wigScores = wigSource.getSummaryScoresForRange(Globals.CHR_ALL, -1, -1, 0);
List<LocusScore> tdfScores = tdfSource.getSummaryScoresForRange(Globals.CHR_ALL, -1, -1, 0);
assertEquals(expHaveChrAll, tdfSource.isChrOrderValid());
if(!expHaveChrAll){
//Ideally we would recalculate the data, but returning nothing
//is preferable to returning incorrect data
if(tdfScores.size() == 0){
return;
}
}
//TODO This test could be more efficient, and we could be more precise
//about chromosome boundaries
int posChecked = 0;
for(String chromo: posChromos){
//We allow a little slop around chromo boundaries
long range = genome.getChromosome(chromo).getLength() / 1000;
long fudge = Math.max(500, range / 100);
range -= 2 * fudge;
long cMin = genome.getCumulativeOffset(chromo) / 1000 + fudge;
long cMax = cMin + range;
for(int ii= 0; ii < wigScores.size(); ii++){
LocusScore wLocus = wigScores.get(ii);
if(wLocus.getStart() >= cMin && wLocus.getEnd() <= cMax){
float wScore = wigScores.get(ii).getScore();
//Just checking our assumption
assert wScore > 0;
}
LocusScore tLocus = tdfScores.get(ii);
if(overlaps(cMin, cMax, tLocus)){
assertTrue("Found negative value in " + chromo + " at " + tLocus.getStart(), tLocus.getScore() >= 0);
posChecked++;
}
}
}
//assertTrue(posChecked > 0);
System.out.println("# Checked for positive values: " + posChecked);
for(String chromo: emptyChromos){
long range = genome.getChromosome(chromo).getLength() / 1000;
long fudge = Math.max(600, range / 100);
range -= 2 * fudge;
long cMin = (genome.getCumulativeOffset(chromo) / 1000) + fudge;
long cMax = cMin + range;
for(LocusScore wLocus: wigScores){
//Just checking our assumption
assert wLocus.getStart() < cMin || wLocus.getEnd() > cMax;