@@ -177,6 +177,29 @@ public void testPairedRecords() throws IOException {
177
177
Assert .assertEquals (results .get (SAMValidationError .Type .INVALID_UNALIGNED_MATE_START .getHistogramString ()).getValue (), 1.0 );
178
178
}
179
179
180
+ @ Test
181
+ public void testSkipMateValidation () throws IOException {
182
+ final SAMRecordSetBuilder samBuilder = new SAMRecordSetBuilder ();
183
+
184
+ for (int i = 0 ; i < 5 ; i ++) {
185
+ samBuilder .addPair (String .valueOf (i ), i , i , i + 100 );
186
+ }
187
+ final Iterator <SAMRecord > records = samBuilder .iterator ();
188
+ records .next ().setMateReferenceName ("*" );
189
+ records .next ().setMateAlignmentStart (Integer .MAX_VALUE );
190
+ records .next ().setMateAlignmentStart (records .next ().getAlignmentStart () + 1 );
191
+ records .next ().setMateNegativeStrandFlag (!records .next ().getReadNegativeStrandFlag ());
192
+ records .next ().setMateReferenceIndex (records .next ().getReferenceIndex () + 1 );
193
+ records .next ().setMateUnmappedFlag (!records .next ().getReadUnmappedFlag ());
194
+
195
+ final Histogram <String > results = executeValidationWithErrorIgnoring (samBuilder .getSamReader (), null , IndexValidationStringency .EXHAUSTIVE , Collections .EMPTY_LIST , true );
196
+
197
+ Assert .assertNull (results .get (SAMValidationError .Type .MISMATCH_FLAG_MATE_NEG_STRAND .getHistogramString ()));
198
+ Assert .assertNull (results .get (SAMValidationError .Type .MISMATCH_FLAG_MATE_UNMAPPED .getHistogramString ()));
199
+ Assert .assertNull (results .get (SAMValidationError .Type .MISMATCH_MATE_ALIGNMENT_START .getHistogramString ()));
200
+ Assert .assertNull (results .get (SAMValidationError .Type .MISMATCH_MATE_REF_INDEX .getHistogramString ()));
201
+ }
202
+
180
203
@ Test (dataProvider = "missingMateTestCases" )
181
204
public void testMissingMate (final SAMFileHeader .SortOrder sortOrder ) throws IOException {
182
205
final SAMRecordSetBuilder samBuilder = new SAMRecordSetBuilder (true , sortOrder );
@@ -584,17 +607,21 @@ public void validateBamFileTerminationTest(final File file, final SAMValidationE
584
607
585
608
private Histogram <String > executeValidation (final SamReader samReader , final ReferenceSequenceFile reference ,
586
609
final IndexValidationStringency stringency ) throws IOException {
587
- return executeValidationWithErrorIgnoring (samReader , reference , stringency , Collections .EMPTY_LIST );
610
+ return executeValidationWithErrorIgnoring (samReader , reference , stringency , Collections .EMPTY_LIST , false );
588
611
}
589
612
590
- private Histogram <String > executeValidationWithErrorIgnoring (final SamReader samReader , final ReferenceSequenceFile reference ,
591
- final IndexValidationStringency stringency , Collection <SAMValidationError .Type > ignoringError ) throws IOException {
613
+ private Histogram <String > executeValidationWithErrorIgnoring (final SamReader samReader ,
614
+ final ReferenceSequenceFile reference ,
615
+ final IndexValidationStringency stringency ,
616
+ final Collection <SAMValidationError .Type > ignoringError ,
617
+ final boolean skipMateValidation ) throws IOException {
592
618
final File outFile = File .createTempFile ("validation" , ".txt" );
593
619
outFile .deleteOnExit ();
594
620
595
621
final PrintWriter out = new PrintWriter (outFile );
596
622
final SamFileValidator samFileValidator = new SamFileValidator (out , 8000 );
597
623
samFileValidator .setIndexValidationStringency (stringency ).setErrorsToIgnore (ignoringError );
624
+ samFileValidator .setSkipMateValidation (skipMateValidation );
598
625
samFileValidator .validateSamFileSummary (samReader , reference );
599
626
600
627
final LineNumberReader reader = new LineNumberReader (new FileReader (outFile ));
0 commit comments