1515import org .labkey .api .pipeline .TaskId ;
1616import org .labkey .api .pipeline .WorkDirectory ;
1717import org .labkey .api .reader .Readers ;
18+ import org .labkey .api .util .FileUtil ;
1819import org .labkey .api .writer .PrintWriters ;
1920import org .labkey .sequenceanalysis .pipeline .AlignmentInitTask ;
2021import org .labkey .sequenceanalysis .pipeline .PrepareAlignerIndexesTask ;
2526import java .io .IOException ;
2627import java .io .PrintWriter ;
2728import java .util .List ;
29+ import java .util .Objects ;
2830
2931import static org .labkey .api .sequenceanalysis .pipeline .SequencePipelineService .SEQUENCE_TOOLS_PARAM ;
3032
@@ -40,35 +42,35 @@ public void setUp() throws Exception
4042 }
4143
4244 @ BeforeClass
43- public static void initialSetUp () throws Exception
45+ public static void initialSetUp ()
4446 {
4547 doInitialSetUp (PROJECT_NAME );
4648 }
4749
4850 private File setupConfigDir (File outDir ) throws IOException
4951 {
50- File baseDir = new File (outDir , "config" );
52+ File baseDir = FileUtil . appendName (outDir , "config" );
5153 if (baseDir .exists ())
5254 {
5355 FileUtils .deleteDirectory (baseDir );
5456 }
5557
56- baseDir .mkdirs ();
58+ FileUtil .mkdirs (baseDir );
5759
5860 if (_sampleData == null )
5961 {
6062 throw new IOException ("_sampleData was null" );
6163 }
6264
63- File source = new File (_sampleData , "remotePipeline" );
65+ File source = FileUtil . appendName (_sampleData , "remotePipeline" );
6466 if (!source .exists ())
6567 {
6668 throw new IOException ("Unable to find file: " + source .getPath ());
6769 }
6870
69- FileUtils .copyFile (new File (source , "sequenceanalysisConfig.xml" ), new File (baseDir , "sequenceanalysisConfig.xml" ));
71+ FileUtils .copyFile (FileUtil . appendName (source , "sequenceanalysisConfig.xml" ), FileUtil . appendName (baseDir , "sequenceanalysisConfig.xml" ));
7072
71- try (PrintWriter writer = PrintWriters .getPrintWriter (new File (baseDir , "pipelineConfig.xml" )); BufferedReader reader = Readers .getReader (new File (source , "pipelineConfig.xml" )))
73+ try (PrintWriter writer = PrintWriters .getPrintWriter (FileUtil . appendName (baseDir , "pipelineConfig.xml" )); BufferedReader reader = Readers .getReader (FileUtil . appendName (source , "pipelineConfig.xml" )))
7274 {
7375 String line ;
7476 while ((line = reader .readLine ()) != null )
@@ -83,12 +85,10 @@ private File setupConfigDir(File outDir) throws IOException
8385
8486 path = path .replaceAll ("\\ \\ " , "/" );
8587 line = line .replaceAll ("@@SEQUENCEANALYSIS_TOOLS@@" , path );
86- _log .info ("Writing to pipelineConfig.xml: " + line );
8788 }
8889 else if (line .contains ("@@WORK_DIR@@" ))
8990 {
9091 line = line .replaceAll ("@@WORK_DIR@@" , outDir .getPath ().replaceAll ("\\ \\ " , "/" ));
91- _log .info ("Writing to pipelineConfig.xml: " + line );
9292 }
9393
9494 writer .println (line );
@@ -113,13 +113,13 @@ protected String getProjectName()
113113 @ Test
114114 public void BasicRemoteJob () throws Exception
115115 {
116- File outDir = new File ( _pipelineRoot , "clusterBootstrap" );
116+ File outDir = FileUtil . appendName ( getPipelineRoot ( _project ) , "clusterBootstrap" );
117117 if (outDir .exists ())
118118 {
119119 FileUtils .deleteDirectory (outDir );
120120 }
121121
122- outDir .mkdirs ();
122+ FileUtil .mkdirs (outDir );
123123
124124 executeJobRemote (outDir , null );
125125
@@ -143,19 +143,19 @@ public void RunBwaRemote() throws Exception
143143 return ;
144144
145145 String jobName = "TestBWAMem_" + System .currentTimeMillis ();
146- JSONObject config = substituteParams (new File (_sampleData , ALIGNMENT_JOB ), jobName );
146+ JSONObject config = substituteParams (FileUtil . appendName (_sampleData , ALIGNMENT_JOB ), jobName );
147147 config .put ("alignment" , "BWA-Mem" );
148148 appendSamplesForAlignment (config , _readsets );
149149
150150 SequenceAlignmentJob job = SequenceAlignmentJob .createForReadsets (_project , _context .getUser (), "RemoteJob1" , "Test of remote pipeline" , config , config .getJSONArray ("readsetIds" ), false ).get (0 );
151- File outDir = new File ( _pipelineRoot , "remoteBwa" );
151+ File outDir = FileUtil . appendName ( getPipelineRoot ( _project ) , "remoteBwa" );
152152 if (outDir .exists ())
153153 {
154154 FileUtils .deleteDirectory (outDir );
155155 }
156156
157- outDir .mkdirs ();
158- job .getLogFile ().getParentFile (). mkdirs ( );
157+ FileUtil .mkdirs (outDir );
158+ FileUtil . mkdirs ( job .getLogFile ().getParentFile ());
159159
160160 _readsets .forEach (rs -> job .getSequenceSupport ().cacheReadset (rs ));
161161
@@ -171,7 +171,7 @@ public void RunBwaRemote() throws Exception
171171 //Now move to remote tasks
172172 job .setActiveTaskId (new TaskId (PrepareAlignerIndexesTask .class ));
173173
174- File jobFile = new File (outDir , "bwaRemote.job.json.txt" );
174+ File jobFile = FileUtil . appendName (outDir , "bwaRemote.job.json.txt" );
175175 job .writeToFile (jobFile );
176176
177177 executeJobRemote (outDir , jobFile );
@@ -191,7 +191,7 @@ public void RunBwaRemote() throws Exception
191191 writeJobLogToLog (job );
192192
193193 _log .info ("Files in job folder: " + job .getLogFile ().getParentFile ().getPath ());
194- for (File f : job .getLogFile ().getParentFile ().listFiles ())
194+ for (File f : Objects . requireNonNull ( job .getLogFile ().getParentFile ().listFiles () ))
195195 {
196196 _log .info (f .getName ());
197197 }
@@ -215,14 +215,14 @@ protected void executeJobRemote(File workDir, @Nullable File jobJson) throws IOE
215215 ProcessBuilder pb = new ProcessBuilder (args );
216216 pb .directory (workDir );
217217
218- _log .info ("Executing job in '" + pb .directory ().getAbsolutePath () + "': " + String .join (" " , pb .command ()));
218+ _log .info ("Executing job in '{}': {}" , pb .directory ().getAbsolutePath (), String .join (" " , pb .command ()));
219219
220220 Process proc ;
221221 try
222222 {
223223 pb .redirectErrorStream (true );
224224 proc = pb .start ();
225- File logFile = new File (workDir , "clusterBootstrap.txt" );
225+ File logFile = FileUtil . appendName (workDir , "clusterBootstrap.txt" );
226226 try (BufferedReader procReader = Readers .getReader (proc .getInputStream ());PrintWriter writer = PrintWriters .getPrintWriter (logFile ))
227227 {
228228 String line ;
0 commit comments