How can I get Queue to include the imports in my QScript?

dmyersturnbulldmyersturnbull Stanford UniversityMember

Right now, when I run "java -jar Queue.jar QScript.scala", scalac ("QScriptManager") complains that it can't find classes and objects that are in the same package as my QScript, as well as methods declared in my package object. When I try to import these explicitly, I get "object is not a member of package x".

How can I tell Queue to pass to scalac all of the files in my package?

I'm using Scala 2.11.4.



Best Answer


  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie

    Are you using an IDE to write your QScript? We find it really helps too make sure all the necessary imports are done correctly.

  • dmyersturnbulldmyersturnbull Stanford UniversityMember

    @Geraldine_VdAuwera said:
    Are you using an IDE to write your QScript? We find it really helps too make sure all the necessary imports are done correctly.

    Thanks for your reply.

    Yes, I'm using IntelliJ IDEA, which picks up the imports and doesn't complain about anything. My project also builds fine using Gradle's scala plugin; scalac shows only minor warnings.

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie

    Hmm. Can you please post the full stack trace you get when you try to run Queue?

  • dmyersturnbulldmyersturnbull Stanford UniversityMember

    Here's what happens when I import the package explicitly with import org.pharmgkb.genome.ngs.BwaMem. BwaMem is a class in the same package as AlignmentPipeline, and both classes are named the same as their files.

    java -Xmx32g -jar ~/utils/queue-3.3.0/Queue.jar -S org/pharmgkb/genome/ngs/AlignmentPipeline.scala
    INFO  16:34:27,374 QScriptManager - Compiling 1 QScript 
    ERROR 16:34:27,605 QScriptManager - AlignmentPipeline.scala:10: object BwaMem is not a member of package org.pharmgkb.genome.ngs 
    ERROR 16:34:27,608 QScriptManager - import org.pharmgkb.genome.ngs.BwaMem 
    ERROR 16:34:27,609 QScriptManager -        ^ 
    ERROR 16:34:28,003 QScriptManager - AlignmentPipeline.scala:60: not found: type BwaMem 
    ERROR 16:34:28,004 QScriptManager -         val aligner = new BwaMem 
    ERROR 16:34:28,005 QScriptManager -                                   ^ 
    ERROR 16:34:28,035 QScriptManager - AlignmentPipeline.scala:70: not found: value createIntermediateFile 
    ERROR 16:34:28,036 QScriptManager -         sorter.output = createIntermediateFile(input, "sorted", "bam") 
    ERROR 16:34:28,036 QScriptManager -                                 ^ 

    Notice that a method declared in the package object, createIntermediateFile, was also not found.


  • dmyersturnbulldmyersturnbull Stanford UniversityMember

    @kshakir said:
    Kind of like using multiple BAMs or multiple VCFs, if you need to scalac multiple files, you'll have to -S each of them. Java 7's globbing support isn't enabled in the GATK argument parsing, so you'll have to specify each separately.

    If it's two or three scala files, use:

    java -jar Queue.jar -S BwaMem.scala -S MyQScript.scala

    Or for a larger number of files, perhaps mix in some command line scripting with something like:

    java -jar Queue.jar `ls *.scala | xargs -n 1 echo -S`

    Another alternative that might work is to pre-scalac your classes using Queue.jar as a "library", and then provide them on the command line with something like:

    java -cp Queue.jar:mySupportClasses org.broadinstitute.gatk.queue.QCommandLine -S MyQScript.scala

    If your support files are turning into a reusable bundle of code, one could also add the GATK-Queue engine as library in a maven-compatible project. We're not in Central yet, but the libraries are buildable from source. See the public/external-example for an example of packaging the gatk-engine. One could do similar for gatk-queue.

    You didn't ask, but my personal preference is to let Queue scalac a number of -S files.

    Thanks, that works well!

    I had assumed passing -S multiple times would imply running multiple QScripts to be run separately.


Sign In or Register to comment.