It looks like you're new here. If you want to get involved, click one of these buttons!
flescai
Posts: 26Member ✭
Hi there, I wanted to reproduce in my variant calling Queue script the same conditional you have in MethodsDevelopmenCallingPipeline, i.e. including InbreedingCoeff depending on the number of samples. However, in that script the number of samples is passed to the Target object as an integer, and I would like to count it from the bam file list passed as an input to the script.
Therefore I followed the method in DataProcessingPipeline, i.e.
import org.broadinstitute.sting.queue.util.QScriptUtils
[...]
@Input(doc="input BAM file - or list of BAM files", fullName="input", shortName="I", required=true)
var bamFile: File = _
[...]
val bamFilesList = QScriptUtils.createSeqFromFile(bamFile)
val sampleNo = bamFilesList.size
But unfortunately, despite DataProcessingPipeline works just fine, when I put these lines in my other script I get the following error:
INFO 12:48:08,616 HelpFormatter - Date/Time: 2012/11/08 12:48:08
INFO 12:48:08,616 HelpFormatter - ----------------------------------------------------------------------
INFO 12:48:08,616 HelpFormatter - ----------------------------------------------------------------------
##### ERROR ------------------------------------------------------------------------------------------
##### ERROR stack trace
org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException: Could not create module HaplotypeCallerStep because Cannot instantiate class (Invocation failure) caused by exception null
at org.broadinstitute.sting.utils.classloader.PluginManager.createByType(PluginManager.java:306)
at org.broadinstitute.sting.utils.classloader.PluginManager.createAllTypes(PluginManager.java:317)
at org.broadinstitute.sting.queue.QCommandLine.execute(QCommandLine.scala:126)
at org.broadinstitute.sting.commandline.CommandLineProgram.start(CommandLineProgram.java:236)
at org.broadinstitute.sting.commandline.CommandLineProgram.start(CommandLineProgram.java:146)
at org.broadinstitute.sting.queue.QCommandLine$.main(QCommandLine.scala:62)
at org.broadinstitute.sting.queue.QCommandLine.main(QCommandLine.scala)
##### ERROR ------------------------------------------------------------------------------------------
##### ERROR A GATK RUNTIME ERROR has occurred (version 2.2-2-gf44cc4e):
##### ERROR
##### ERROR Please visit the wiki to see if this is a known problem
##### ERROR If not, please post the error, with stack trace, to the GATK forum
##### ERROR Visit our website and forum for extensive documentation and answers to
##### ERROR commonly asked questions http://www.broadinstitute.org/gatk
##### ERROR
##### ERROR MESSAGE: Could not create module HaplotypeCallerStep because Cannot instantiate class (Invocation failure) caused by exception null
##### ERROR ------------------------------------------------------------------------------------------
I tried several alternatives looking at the imports in DataProcessingPipeline but maybe I am missing something. Could you please advise?
thanks very much Francesco
Johan_Dahlberg
Posts: 36 ✭
The problem is that you are calling QScriptUtils.createSeqFromFile(bamFile) in the body of the script. I think (my knowledge of Scala is not as complete as I would like it to be) this causes the scala compiler to try to include the code in the constructor, and thus calling createSeqFromFile with null, as this variable is only set at runtime. This causes the script to fail. If you put the function call in the script portion you should be fine. :) There is a minimal example of this which works on my end:
package org.broadinstitute.sting.queue.qscripts
import org.broadinstitute.sting.queue.QScript
import org.broadinstitute.sting.queue.util.QScriptUtils
class HaplotypeCallerStep extends QScript {
// Create an alias 'qscript' to be able to access variables
// in the HaplotypeCallerStep.
// 'qscript' is now the same as 'HaplotypeCallerStep.this'
qscript =>
// Required arguments. All initialized to empty values.
@Input(doc="input BAM file - or list of BAM files", fullName="input", shortName="I", required=true)
var bamFile: File = _
/***************************************************
* main script
***************************************************/
def script() {
val bamFilesList = QScriptUtils.createSeqFromFile(bamFile)
val sampleNo = bamFilesList.size
System.err.println("------ samples ------")
System.err.println(sampleNo)
System.err.println("======================")
}
}
Hope this solution works for you.
Answers
Hi Francesco,
Unfortunately, we just don't have the resources to help people with programming questions. Perhaps you'll have better luck posting this in the Ask the Community section.
I will say that it looks like your problem is unrelated and has something to do with the Haplotype Caller. Perhaps you are using GATK lite? Good luck!
Eric Banks, PhD -- Group Leader, Methods Development, MPG, Broad Institute of Harvard and MIT
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Hi Eric, I assumed QScriptUtils was part of Queue and createSeqFromFile not to be a general scala method, and therefore that's why I posted here the question.
I am using GATK2-2.2 full version, not the light one.
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·QScriptUtils and createSeqFromFile are part of Queue. But I'm 99% sure that inn't what is causing your problem. As Eric points out, it is more likely something wrong in the haplotype caller part. As stated in the error message: "Could not create module HaplotypeCallerStep because Cannot instantiate class (Invocation failure) caused by exception null"
If you can post your entire script here, or somewhere else, it would be easier to give an answer as to what is causing the problem. My guess is that it is caused by a problem in your extension class for the Haplotype caller.
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Thanks Johan, that's really very kind of you.
Apart the few lines I wrote above, I didn't modify the extension of the class in other parts, and without reference to import org.broadinstitute.sting.queue.util.QScriptUtils it works (if I don't add the method of course)
This is my script, it might be useful to other people as well. Thanks
- Spam
- Abuse
- Troll
1 · Off Topic Disagree Agree 1Like WTF ·Hi Francesco -
Is it failing when you specify a "list of BAM files"? Because I would expect that to cause problems right here:
You should be giving it
bamFilesList(the actual bams), notbamFile(the file containing a list of filenames). The same problem is in AnnotationArguments. I don't know if that would lead to the error you're seeing, though...- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·thanks, but the script works perfectly that way if I don't add the lines I reported initially. the sintax you refer to is present in ExampleUnifiedGenotyper.scala provided with Queue examples
the
bamFilesListis something I create here for the sole purpose of calculating the size, i.e. the number of samples- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Just to clarify, if I comment out these three lines
the script I posted works just fine.
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·FYI, I have moved this thread to "Ask the community". Carry on, folks; and thanks for jumping in to help.
Geraldine Van der Auwera, PhD
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Hmm, didn't realize the input would work that way. That's pretty cool.
In my own script, I walk through the BAMs and check the RGs to get a count of samples. Here's my code, I'm pretty sure I adapted
countSamplesfrom DataProcessingPipeline:- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Indeed, that's precisely where I found the method
createSeqFromFileIn the count function, you pass a
countSamples(bamFiles: Seq[File])which is defined as a Seq.Because it's been converted by that method I'm interested in.
You can see it is a method of
QScriptUtilsIn order to be able to use it, you need to import it with
So I'm doing precisely the same as in DataProcessingPipeline, except for the
.sizemethod, which is anyway a method of Seq.However, as soon as I put that import into the HaplotypeCaller class, it seems not capable to instantiate it anymore.
GATK team members say it has nothing to do with their code... but then I don't understand why the very same code of just three lines conflicts with a script working otherwise.
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Can you recreate the problem in a minimal script? Perhaps your copy of Queue is corrupt
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·Thanks Johan that's great! which confirms my knowledge of scala proximal to zero :-)
I've simply moved the code into the class Target now, and it works.
this way I can add a conditional on the number of samples anywhere I want in the other classes, outside the main script.
thanks a lot!!
Francesco
- Spam
- Abuse
- Troll
0 · Off Topic Disagree Agree Like WTF ·