}
WriteHeader(OUTPUT_FORMAT, out);
//initialize reference
ReferenceSequenceFile reference_file = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE);
//initialize auxiliary data
InitKnownCalls();
InitSummaryMetrics();
//initialize SAM/BAM data iterators
List<SamPositionIterator> positionIterators = new ArrayList<SamPositionIterator>();
if (REGION_FILE != null) {
BufferedReader region_reader = null;
String line = null;
try {
region_reader = new BufferedReader(new FileReader(REGION_FILE));
} catch (FileNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
try {
while ((line = region_reader.readLine()) != null) {
String[] tokens = line.split(":");
String seq_name = tokens[0];
String positions = tokens[1];
tokens = positions.split("-");
int start = 0, end = 0;
try {
start = Integer.parseInt(tokens[0]);
end = Integer.parseInt(tokens[1]);
} catch (Exception e) {
System.err.println("Error parsing definition string");
}
SamPositionIterator position_iterator = new SamPositionIterator(INPUT, MINIMUM_COVERAGE, MAXIMUM_COVERAGE, MINIMUM_MAPQ, MIN_MATE_DISTANCE, MAX_MATE_DISTANCE, MINIMUM_BASE_QUALITY, MIN_ALIGNMENT_SCORE, seq_name, start, end);
positionIterators.add(position_iterator);
}
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} else if (REGION.equals("")) {
SamPositionIterator position_iterator = new SamPositionIterator(INPUT, MINIMUM_COVERAGE, MAXIMUM_COVERAGE, MINIMUM_MAPQ, MIN_MATE_DISTANCE, MAX_MATE_DISTANCE, MINIMUM_BASE_QUALITY, MIN_ALIGNMENT_SCORE);
positionIterators.add(position_iterator);
} else {
//split the region string into sequence name/beginning/end
String[] tokens = REGION.split(",");
int start = 0, end = 0;
try {
start = Integer.parseInt(tokens[1]);
end = Integer.parseInt(tokens[2]);
} catch (Exception e) {
System.err.println("Error parsing definition string");
}
SamPositionIterator position_iterator = new SamPositionIterator(INPUT, MINIMUM_COVERAGE, MAXIMUM_COVERAGE, MINIMUM_MAPQ, MIN_MATE_DISTANCE, MAX_MATE_DISTANCE, MINIMUM_BASE_QUALITY, MIN_ALIGNMENT_SCORE, tokens[0], start, end);
positionIterators.add(position_iterator);
}
SolSNPCaller s = new SolSNPCaller(STRAND_MODE, CALL_BIAS, PLOIDY);
SNPCall SNP = new SNPCall();
SNPCall known_call = new SNPCall();
int coverage;
int previous_position = 0;
final Map<SNPCallPair, TreeMap<Integer, Long>> calltable_validation = new HashMap<SNPCallPair, TreeMap<Integer, Long>>();
ReferenceSequence reference = null;
while ((reference = reference_file.nextSequence()) != null) {
for (SamPositionIterator position_iterator : positionIterators) {
position_iterator.nextSequence();
String ref_name = reference.getName();
if (!position_iterator.getCurrentSequence().equals(ref_name))