@@ -49,37 +49,16 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
4949 {
5050 AnalysisOutputImpl output = new AnalysisOutputImpl ();
5151
52- File inputFile = inputBam ;
53- if (SequenceUtil .FILETYPE .cram .getFileType ().isType (inputFile ))
54- {
55- CramToBam samtoolsRunner = new CramToBam (getPipelineCtx ().getLogger ());
56- File bam = new File (getPipelineCtx ().getWorkingDirectory (), inputFile .getName ().replaceAll (".cram$" , ".bam" ));
57- File bamIdx = new File (bam .getPath () + ".bai" );
58- if (!bamIdx .exists ())
59- {
60- samtoolsRunner .convert (inputFile , bam , referenceGenome .getWorkingFastaFile (), SequencePipelineService .get ().getMaxThreads (getPipelineCtx ().getLogger ()));
61- new SamtoolsIndexer (getPipelineCtx ().getLogger ()).execute (bam );
62- }
63- else
64- {
65- getPipelineCtx ().getLogger ().debug ("BAM index exists, will not re-convert CRAM" );
66- }
67-
68- inputFile = bam ;
69-
70- output .addIntermediateFile (bam );
71- output .addIntermediateFile (bamIdx );
72- }
73-
7452 List <String > args = new ArrayList <>();
7553 args .add (getExe ().getPath ());
7654 args .add ("discover" );
7755
7856 args .add ("--bam" );
79- args .add (inputFile .getPath ());
57+ args .add (inputBam .getPath ());
8058
59+ // NOTE: sawfish stores the absolute path of the FASTA in the output JSON, so dont rely on working copies:
8160 args .add ("--ref" );
82- args .add (referenceGenome .getWorkingFastaFile ().getPath ());
61+ args .add (referenceGenome .getSourceFastaFile ().getPath ());
8362
8463 File svOutDir = new File (outputDir , "sawfish" );
8564 args .add ("--output-dir" );
@@ -123,41 +102,4 @@ private File getExe()
123102 {
124103 return SequencePipelineService .get ().getExeForPackage ("SAWFISHPATH" , "sawfish" );
125104 }
126-
127- private static class CramToBam extends SamtoolsRunner
128- {
129- public CramToBam (Logger log )
130- {
131- super (log );
132- }
133-
134- public void convert (File inputCram , File outputBam , File fasta , @ Nullable Integer threads ) throws PipelineJobException
135- {
136- getLogger ().info ("Converting CRAM to BAM" );
137-
138- execute (getParams (inputCram , outputBam , fasta , threads ));
139- }
140-
141- private List <String > getParams (File inputCram , File outputBam , File fasta , @ Nullable Integer threads )
142- {
143- List <String > params = new ArrayList <>();
144- params .add (getSamtoolsPath ().getPath ());
145- params .add ("view" );
146- params .add ("-b" );
147- params .add ("-T" );
148- params .add (fasta .getPath ());
149- params .add ("-o" );
150- params .add (outputBam .getPath ());
151-
152- if (threads != null )
153- {
154- params .add ("-@" );
155- params .add (String .valueOf (threads ));
156- }
157-
158- params .add (inputCram .getPath ());
159-
160- return params ;
161- }
162- }
163105}
0 commit comments