optionally check that the records are sorted.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@131 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
149ac3d96c
commit
dfe50ce773
|
|
@ -15,6 +15,7 @@ public class ValidateSAM extends CommandLineProgram {
|
||||||
@Option(shortName="I", doc="SAM or BAM file for validation") public File INPUT_FILE;
|
@Option(shortName="I", doc="SAM or BAM file for validation") public File INPUT_FILE;
|
||||||
@Option(shortName="M", doc="Maximum number of errors to detect before exiting", optional=true) public String MAX_ERRORS_ARG = "-1";
|
@Option(shortName="M", doc="Maximum number of errors to detect before exiting", optional=true) public String MAX_ERRORS_ARG = "-1";
|
||||||
@Option(shortName="S", doc="How strict should we be with validation", optional=true) public String STRICTNESS_ARG = "strict";
|
@Option(shortName="S", doc="How strict should we be with validation", optional=true) public String STRICTNESS_ARG = "strict";
|
||||||
|
@Option(shortName="SORTED", doc="Check that the SAM file is sorted", optional=true) public boolean CHECK_SORTED_ARG = false;
|
||||||
|
|
||||||
private long startTime = -1;
|
private long startTime = -1;
|
||||||
|
|
||||||
|
|
@ -51,16 +52,34 @@ public class ValidateSAM extends CommandLineProgram {
|
||||||
|
|
||||||
int nRecords = 0;
|
int nRecords = 0;
|
||||||
int nErrors = 0;
|
int nErrors = 0;
|
||||||
|
|
||||||
|
SAMRecord last_record = null;
|
||||||
|
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
nRecords++;
|
nRecords++;
|
||||||
try {
|
try {
|
||||||
final SAMRecord ri = iter.next();
|
final SAMRecord ri = iter.next();
|
||||||
|
|
||||||
|
if (CHECK_SORTED_ARG &&
|
||||||
|
(last_record != null) &&
|
||||||
|
(ri.getReferenceName() == last_record.getReferenceName()) &&
|
||||||
|
(ri.getAlignmentStart() < last_record.getAlignmentStart()))
|
||||||
|
{
|
||||||
|
System.out.println("Not sorted!");
|
||||||
|
System.out.println(last_record.format());
|
||||||
|
System.out.println(ri.format() + "\n");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_record = ri;
|
||||||
|
|
||||||
} catch (Exception ioe) {
|
} catch (Exception ioe) {
|
||||||
nErrors++;
|
nErrors++;
|
||||||
System.out.println("[VALIDATION FAILURE IN RECORD]: " + ioe);
|
System.out.println("[VALIDATION FAILURE IN RECORD]: " + ioe);
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( MAX_ERRORS > -1 && nErrors >= MAX_ERRORS ) {
|
if ( MAX_ERRORS > -1 && nErrors >= MAX_ERRORS ) {
|
||||||
System.out.println("Maximum number of errors encountered " + nErrors);
|
System.out.println("Maximum number of errors encountered " + nErrors);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue