Skip to content
Snippets Groups Projects
Commit 110b16b0 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Merge branch 'feature-prerelease_fixes' into 'develop'

Feature prerelease fixes

Commit messages should be clear enough :).

See merge request !61
parents d057ab01 b83f5736
No related branches found
No related tags found
No related merge requests found
......@@ -19,9 +19,10 @@ import nl.lumc.sasc.biopet.core.ToolCommand
object ExtractAlignedFastq extends ToolCommand {
/** type alias for Fastq input (may or may not be paired) */
type FastqInput = (FastqRecord, Option[FastqRecord])
/** function to get FastqRecord ID */
/** Get the FastqRecord ID */
def fastqId(rec: FastqRecord) = rec.getReadHeader.split(" ")(0)
/**
......@@ -54,14 +55,13 @@ object ExtractAlignedFastq extends ToolCommand {
// by the Interval constructor only accepting ints
def intFromCoord(s: String): Int = s.replaceAll(",", "").replaceAll("\\.", "").toInt
inStrings.map(x => x match {
inStrings.map {
case ptn1(chr, start, end) => new Interval(chr, intFromCoord(start), intFromCoord(end))
case ptn2(chr, start) =>
val startCoord = intFromCoord(start)
new Interval(chr, startCoord, startCoord)
case _ => throw new IllegalArgumentException("Invalid interval string: " + x)
})
.toIterator
}.toIterator
}
/**
......@@ -125,6 +125,13 @@ object ExtractAlignedFastq extends ToolCommand {
}
}
/**
* Extracts reads from the given input Fastq file and writes to a new output Fastq file
*
* @param memFunc Predicate for extracting reads. If evaluates to true, the read is extracted.
* @param inputFastq1 Input [[FastqReader]] object.
* @param outputFastq1 Output [[BasicFastqWriter]] object.
*/
def extractReads(memFunc: FastqInput => Boolean,
inputFastq1: FastqReader, outputFastq1: BasicFastqWriter): Unit =
inputFastq1.iterator.asScala
......@@ -132,6 +139,15 @@ object ExtractAlignedFastq extends ToolCommand {
.filter(rec => memFunc(rec._1, rec._2))
.foreach(rec => outputFastq1.write(rec._1))
/**
* Extracts reads from the given input Fastq pairs and writes to new output Fastq pair files
*
* @param memFunc Predicate for extracting reads. If evaluates to true, the read is extracted.
* @param inputFastq1 Input [[FastqReader]] object for pair 1.
* @param outputFastq1 Input [[FastqReader]] object for pair 2.
* @param inputFastq2 Output [[BasicFastqWriter]] object for pair 1.
* @param outputFastq2 Output [[BasicFastqWriter]] object for pair 2.
*/
def extractReads(memFunc: FastqInput => Boolean,
inputFastq1: FastqReader, outputFastq1: BasicFastqWriter,
inputFastq2: FastqReader, outputFastq2: BasicFastqWriter): Unit =
......@@ -143,6 +159,7 @@ object ExtractAlignedFastq extends ToolCommand {
outputFastq2.write(rec._2)
})
/** Default arguments */
case class Args(inputBam: File = new File(""),
intervals: List[String] = List.empty[String],
inputFastq1: File = new File(""),
......@@ -152,6 +169,7 @@ object ExtractAlignedFastq extends ToolCommand {
minMapQ: Int = 0,
commonSuffixLength: Int = 0) extends AbstractArgs
/** Command line argument parser */
class OptParser extends AbstractOptParser {
head(
......@@ -213,6 +231,7 @@ object ExtractAlignedFastq extends ToolCommand {
}
}
/** Parses the command line argument */
def parseArgs(args: Array[String]): Args =
new OptParser()
.parse(args, Args())
......
......@@ -47,12 +47,7 @@ class WipeReads(val root: Configurable) extends BiopetJavaCommandLineFunction {
object WipeReads extends ToolCommand {
/**
* Creates a SamReader object from an input BAM file, ensuring it is indexed
*
* @param inBam input BAM file
* @return
*/
/** Creates a SamReader object from an input BAM file, ensuring it is indexed */
private def prepInBam(inBam: File): SamReader = {
val bam = SamReaderFactory
.make()
......@@ -62,6 +57,7 @@ object WipeReads extends ToolCommand {
bam
}
/** Creates a [[SAMFileWriter]] object for writing, indexed */
private def prepOutBam(outBam: File, templateBam: File,
writeIndex: Boolean = true, async: Boolean = true): SAMFileWriter =
new SAMFileWriterFactory()
......@@ -336,6 +332,7 @@ object WipeReads extends ToolCommand {
}
}
/** Default arguments */
case class Args(inputBam: File = new File(""),
targetRegions: File = new File(""),
outputBam: File = new File(""),
......@@ -348,6 +345,7 @@ object WipeReads extends ToolCommand {
bloomSize: Long = 70000000,
bloomFp: Double = 4e-7) extends AbstractArgs
/** Command line argument parser */
class OptParser extends AbstractOptParser {
head(
......@@ -418,12 +416,7 @@ object WipeReads extends ToolCommand {
}
/**
* Parses the command line argument
*
* @param args Array of arguments
* @return
*/
/** Parses the command line argument */
def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args())
.getOrElse(sys.exit(1))
......
......@@ -11,7 +11,7 @@ import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
class LnUnitTest extends TestNGSuite with Matchers {
class LnTest extends TestNGSuite with Matchers {
@Test(description = "Target and link in the same directory, relative set to true")
def testSameLevelRelative() {
......
......@@ -17,7 +17,7 @@ import org.testng.annotations.{ DataProvider, Test }
import htsjdk.samtools.util.Interval
import htsjdk.samtools.fastq.{ BasicFastqWriter, FastqReader, FastqRecord }
class ExtractAlignedFastqUnitTest extends TestNGSuite with MockitoSugar with Matchers {
class ExtractAlignedFastqTest extends TestNGSuite with MockitoSugar with Matchers {
import ExtractAlignedFastq._
......
......@@ -25,7 +25,7 @@ import org.scalatest.mock.MockitoSugar
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
class WipeReadsUnitTest extends TestNGSuite with MockitoSugar with Matchers {
class WipeReadsTest extends TestNGSuite with MockitoSugar with Matchers {
import WipeReads._
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment