Commit d7df6de4 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Code style fixes

parent 8a204c14
......@@ -19,7 +19,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.RscriptCommandLineFunction
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/**
* Extension for en general line plot with R
......
......@@ -15,20 +15,20 @@
*/
package nl.lumc.sasc.biopet.tools
import java.io.{PrintWriter, InputStream, File}
import java.io.{ PrintWriter, InputStream, File }
import java.util
import htsjdk.samtools.util.Interval
import htsjdk.samtools.{QueryInterval, SAMRecord, SamReader, SamReaderFactory}
import htsjdk.samtools.{ QueryInterval, SAMRecord, SamReader, SamReaderFactory }
import htsjdk.tribble.AbstractFeatureReader._
import htsjdk.tribble.{AbstractFeatureReader, TabixFeatureReader}
import htsjdk.tribble.bed.{BEDFeature, SimpleBEDFeature, BEDCodec, FullBEDFeature}
import htsjdk.variant.variantcontext.writer.{AsyncVariantContextWriter, VariantContextWriterBuilder}
import htsjdk.variant.variantcontext.{VariantContext, VariantContextBuilder}
import htsjdk.variant.vcf.{VCFFileReader, VCFHeaderLineCount, VCFHeaderLineType, VCFInfoHeaderLine}
import htsjdk.tribble.{ AbstractFeatureReader, TabixFeatureReader }
import htsjdk.tribble.bed.{ BEDFeature, SimpleBEDFeature, BEDCodec, FullBEDFeature }
import htsjdk.variant.variantcontext.writer.{ AsyncVariantContextWriter, VariantContextWriterBuilder }
import htsjdk.variant.variantcontext.{ VariantContext, VariantContextBuilder }
import htsjdk.variant.vcf.{ VCFFileReader, VCFHeaderLineCount, VCFHeaderLineType, VCFInfoHeaderLine }
import nl.lumc.sasc.biopet.core.ToolCommand
import nl.lumc.sasc.biopet.extensions.rscript.ScatterPlot
import nl.lumc.sasc.biopet.utils.intervals.{BedRecord, BedRecordList}
import nl.lumc.sasc.biopet.utils.intervals.{ BedRecord, BedRecordList }
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
......@@ -54,10 +54,10 @@ object RegionAfCount extends ToolCommand {
c.copy(scatterpPlot = Some(x))
}
opt[File]('V', "vcfFile") unbounded () minOccurs 1 action { (x, c) =>
c.copy(vcfFiles = c.vcfFiles ::: x :: Nil )
c.copy(vcfFiles = c.vcfFiles ::: x :: Nil)
}
opt[Unit]("exonsOnly") unbounded () action { (x, c) =>
c.copy(exonsOnly = true )
c.copy(exonsOnly = true)
}
}
......@@ -87,7 +87,7 @@ object RegionAfCount extends ToolCommand {
for (variant <- it) {
val sum = (variant.getAttribute("AF", 0) match {
case a: util.ArrayList[_] => a.map(_.toString.toDouble).toArray
case s => Array(s.toString.toDouble)
case s => Array(s.toString.toDouble)
}).sum
bedRecords
.overlapWith(BedRecord(variant.getContig, variant.getStart, variant.getEnd))
......
package nl.lumc.sasc.biopet.tools
import java.io.File
import nl.lumc.sasc.biopet.core.ToolCommand
import nl.lumc.sasc.biopet.utils.intervals.BedRecordList
/**
* Created by pjvanthof on 22/08/15.
*/
object SquishBed extends ToolCommand {
case class Args(input: File = null, output: File = null) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('I', "input") required () valueName "<file>" action { (x, c) =>
c.copy(input = x)
}
opt[File]('o', "output") required () unbounded () valueName "<file>" action { (x, c) =>
c.copy(output = x)
}
}
/**
* @param args the command line arguments
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1)
if (!cmdArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + cmdArgs.input)
val records = BedRecordList.fromFile(cmdArgs.input).squishBed()
}
}
......@@ -24,7 +24,7 @@ case class BedRecord(chr: String,
Some(BedRecordList.fromList(for (i <- 0 to blockCount.get) yield {
val exonNumber = strand match {
case Some(false) => blockCount.get - i
case _ => i + 1
case _ => i + 1
}
val record = BedRecord(chr, start + blockStarts(i), start + blockStarts(i) + blockSizes(i),
name.map(_ + s"_exon-$exonNumber"))
......@@ -37,7 +37,7 @@ case class BedRecord(chr: String,
Some(BedRecordList.fromList(for (i <- 0 to (blockCount.get - 1)) yield {
val intronNumber = strand match {
case Some(false) => blockCount.get - i
case _ => i + 1
case _ => i + 1
}
val record = BedRecord(chr, start + start + blockStarts(i) + blockSizes(i) + 1, start + blockStarts(i + 1) - 1,
name.map(_ + s"_intron-$intronNumber"))
......@@ -65,11 +65,11 @@ object BedRecord {
values.lift(5).map(_ match {
case "-" => false
case "+" => true
case _ => throw new IllegalStateException("Strand (column 6) must be '+' or '-'")
case _ => throw new IllegalStateException("Strand (column 6) must be '+' or '-'")
}),
values.lift(6).map(_.toInt),
values.lift(7)map(_.toInt),
values.lift(8).map(_.split(",", 3).map(_.toInt)).map(x => (x.lift(0).getOrElse(0),x.lift(1).getOrElse(0),x.lift(2).getOrElse(0))),
values.lift(7) map (_.toInt),
values.lift(8).map(_.split(",", 3).map(_.toInt)).map(x => (x.lift(0).getOrElse(0), x.lift(1).getOrElse(0), x.lift(2).getOrElse(0))),
values.lift(9).map(_.toInt),
values.lift(10).map(_.split(",").map(_.toInt)).getOrElse(Array()),
values.lift(11).map(_.split(",").map(_.toInt)).getOrElse(Array())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment