From c4c2a7255c2b46821a2327a67cb2dc4c5f6160b3 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Mon, 21 Mar 2016 12:43:35 +0100 Subject: [PATCH] Style fixes --- .../extensions/gatk/SelectVariants.scala | 2 +- .../biopet/extensions/tools/GensToVcf.scala | 4 +- .../nl/lumc/sasc/biopet/tools/GensToVcf.scala | 39 +++++++-------- .../biopet/pipelines/gwastest/GwasTest.scala | 47 ++++++++++--------- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/gatk/SelectVariants.scala b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/gatk/SelectVariants.scala index 1308a836f..65abc6098 100644 --- a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/gatk/SelectVariants.scala +++ b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/gatk/SelectVariants.scala @@ -18,7 +18,7 @@ package nl.lumc.sasc.biopet.extensions.gatk import java.io.File import nl.lumc.sasc.biopet.utils.config.Configurable -import org.broadinstitute.gatk.utils.commandline.{Input, Output} +import org.broadinstitute.gatk.utils.commandline.{ Input, Output } /** * Extension for CombineVariants from GATK diff --git a/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/GensToVcf.scala b/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/GensToVcf.scala index b94d24ac7..4cb4548a0 100644 --- a/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/GensToVcf.scala +++ b/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/GensToVcf.scala @@ -17,10 +17,10 @@ package nl.lumc.sasc.biopet.extensions.tools import java.io.File -import nl.lumc.sasc.biopet.core.{Reference, ToolCommandFunction} +import nl.lumc.sasc.biopet.core.{ Reference, ToolCommandFunction } import nl.lumc.sasc.biopet.utils.Logging import nl.lumc.sasc.biopet.utils.config.Configurable -import org.broadinstitute.gatk.utils.commandline.{Output, Input} +import org.broadinstitute.gatk.utils.commandline.{ Output, Input } /** * diff --git a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/GensToVcf.scala b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/GensToVcf.scala index 18657c086..6b989655a 100644 --- a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/GensToVcf.scala +++ b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/GensToVcf.scala @@ -14,8 +14,8 @@ import scala.collection.JavaConversions._ import scala.io.Source /** - * Created by pjvanthof on 15/03/16. - */ + * Created by pjvanthof on 15/03/16. + */ object GensToVcf extends ToolCommand { case class Args(inputGenotypes: File = null, @@ -79,23 +79,24 @@ object GensToVcf extends ToolCommand { val alt = Allele.create(genotypeValues(4)) val start = genotypeValues(2).toInt val end = ref.length - 1 + start - val genotypes = samples.toList.zipWithIndex.map { case (sampleName, index) => - val gps = Array( - genotypeValues(5 + (index * 3)), - genotypeValues(5 + (index * 3) + 1), - genotypeValues(5 + (index * 3) + 2) - ).map(_.toDouble) - val alleles = gps.indexOf(gps.max) match { - case 0 => List(ref, ref) - case 1 => List(ref, alt) - case 2 => List(alt, alt) - } - new GenotypeBuilder() - .name(sampleName) - .alleles(alleles) - .attribute("GP", gps) - .PL(gps) - .make() + val genotypes = samples.toList.zipWithIndex.map { + case (sampleName, index) => + val gps = Array( + genotypeValues(5 + (index * 3)), + genotypeValues(5 + (index * 3) + 1), + genotypeValues(5 + (index * 3) + 2) + ).map(_.toDouble) + val alleles = gps.indexOf(gps.max) match { + case 0 => List(ref, ref) + case 1 => List(ref, alt) + case 2 => List(alt, alt) + } + new GenotypeBuilder() + .name(sampleName) + .alleles(alleles) + .attribute("GP", gps) + .PL(gps) + .make() } val builder = (new VariantContextBuilder) diff --git a/public/gwas-test/src/main/scala/nl/lumc/sasc/biopet/pipelines/gwastest/GwasTest.scala b/public/gwas-test/src/main/scala/nl/lumc/sasc/biopet/pipelines/gwastest/GwasTest.scala index 9e8d529b7..df2af5d9e 100644 --- a/public/gwas-test/src/main/scala/nl/lumc/sasc/biopet/pipelines/gwastest/GwasTest.scala +++ b/public/gwas-test/src/main/scala/nl/lumc/sasc/biopet/pipelines/gwastest/GwasTest.scala @@ -2,16 +2,16 @@ package nl.lumc.sasc.biopet.pipelines.gwastest import java.io.File -import nl.lumc.sasc.biopet.core.{PipelineCommand, Reference, BiopetQScript} -import nl.lumc.sasc.biopet.extensions.gatk.{SelectVariants, CombineVariants} +import nl.lumc.sasc.biopet.core.{ PipelineCommand, Reference, BiopetQScript } +import nl.lumc.sasc.biopet.extensions.gatk.{ SelectVariants, CombineVariants } import nl.lumc.sasc.biopet.extensions.tools.GensToVcf import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.intervals.BedRecordList import org.broadinstitute.gatk.queue.QScript /** - * Created by pjvanthof on 16/03/16. - */ + * Created by pjvanthof on 16/03/16. + */ class GwasTest(val root: Configurable) extends QScript with BiopetQScript with Reference { def this() = this(null) @@ -24,10 +24,11 @@ class GwasTest(val root: Configurable) extends QScript with BiopetQScript with R else { if (config.contains("input_gens")) { val gens: List[Any] = configValue2list(config("input_gens")) - Some(gens.map{ case value: Map[String, Any] => - GensInput(new File(value("genotypes").toString), - value.get("info").map(x => new File(x.toString)), - value("contig").toString) + Some(gens.map { + case value: Map[String, Any] => + GensInput(new File(value("genotypes").toString), + value.get("info").map(x => new File(x.toString)), + value("contig").toString) }) } else None } @@ -60,24 +61,24 @@ class GwasTest(val root: Configurable) extends QScript with BiopetQScript with R } val snpTests = BedRecordList.fromReference(referenceFasta()) - .scatter(config("bin_size", default = 10^6)) + .scatter(config("bin_size", default = 10 ^ 6)) .allRecords.map { region => - val regionDir = new File(outputDir, "snptest" + File.separator + region.chr) - regionDir.mkdirs() - val bedFile = new File(regionDir, s"${region.chr}-${region.start + 1}-${region.end}.bed") - BedRecordList.fromList(List(region)).writeToFile(bedFile) - bedFile.deleteOnExit() + val regionDir = new File(outputDir, "snptest" + File.separator + region.chr) + regionDir.mkdirs() + val bedFile = new File(regionDir, s"${region.chr}-${region.start + 1}-${region.end}.bed") + BedRecordList.fromList(List(region)).writeToFile(bedFile) + bedFile.deleteOnExit() - val sv = new SelectVariants(this) - sv.inputFiles :+= vcfFile - sv.outputFile = new File(regionDir, s"${region.chr}-${region.start + 1}-${region.end}.vcf.gz") - sv.intervals :+= bedFile - sv.isIntermediate = true - add(sv) + val sv = new SelectVariants(this) + sv.inputFiles :+= vcfFile + sv.outputFile = new File(regionDir, s"${region.chr}-${region.start + 1}-${region.end}.vcf.gz") + sv.intervals :+= bedFile + sv.isIntermediate = true + add(sv) - //TODO: snptest - (region -> "") - } + //TODO: snptest + (region -> "") + } } } -- GitLab