Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanup needed for bigdatagenomics/cannoli#65 #1704

Merged
merged 2 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,18 @@ class InterleavedFASTQInFormatter private (
outputOriginalBaseQualities = writeOriginalQualities) + "\n"

// write both to the output stream
os.write(fastq1.getBytes)
os.write(fastq2.getBytes)
// ensure that reads are ordered properly if ordering is known (see #1702)
if (read1.getReadInFragment == 0 &&
read2.getReadInFragment == 1) {
os.write(fastq1.getBytes)
os.write(fastq2.getBytes)
} else if (read1.getReadInFragment == 1 &&
read2.getReadInFragment == 0) {
os.write(fastq2.getBytes)
os.write(fastq1.getBytes)
} else {
log.warn("Improper pair of reads in fragment %s. Dropping...".format(p))
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import scala.collection.mutable.ListBuffer
* An OutFormatter that automatically infers whether the piped input is SAM or
* BAM. Autodetecting streamed CRAM is not currently supported.
*/
class AnySAMOutFormatter extends OutFormatter[AlignmentRecord] {
case class AnySAMOutFormatter(stringency: ValidationStringency) extends OutFormatter[AlignmentRecord] {

def this() = this(ValidationStringency.STRICT)

/**
* Reads alignment records from an input stream. Autodetects SAM/BAM format.
Expand All @@ -41,6 +43,7 @@ class AnySAMOutFormatter extends OutFormatter[AlignmentRecord] {

// make reader
val reader = SamReaderFactory.makeDefault()
.validationStringency(stringency)
.open(SamInputResource.of(is))

SAMIteratorConverter(reader)
Expand Down