11package org .labkey .sequenceanalysis .run ;
22
3+ import htsjdk .samtools .util .IOUtil ;
4+ import org .apache .commons .io .FileUtils ;
35import org .apache .commons .lang3 .SystemUtils ;
46import org .apache .logging .log4j .Logger ;
57import org .jetbrains .annotations .Nullable ;
2729import org .labkey .api .sequenceanalysis .run .AbstractCommandWrapper ;
2830import org .labkey .api .sequenceanalysis .run .SimpleScriptWrapper ;
2931import org .labkey .api .util .Compress ;
32+ import org .labkey .api .util .FileUtil ;
3033import org .labkey .api .util .Pair ;
34+ import org .labkey .api .writer .PrintWriters ;
3135import org .labkey .sequenceanalysis .SequenceAnalysisModule ;
3236import org .labkey .sequenceanalysis .SequenceAnalysisSchema ;
3337
3438import java .io .File ;
3539import java .io .IOException ;
40+ import java .io .PrintWriter ;
3641import java .nio .file .Files ;
3742import java .sql .SQLException ;
3843import java .util .ArrayList ;
@@ -183,6 +188,7 @@ public void processFilesOnWebserver(PipelineJob job, SequenceAnalysisJobSupport
183188 public void processFilesRemote (List <Readset > readsets , JobContext ctx ) throws UnsupportedOperationException , PipelineJobException
184189 {
185190 Readset rs = readsets .get (0 );
191+ final String timestamp = FileUtil .getTimestamp ();
186192 for (ReadData rd : rs .getReadData ())
187193 {
188194 if (rd .isArchived ())
@@ -199,11 +205,14 @@ public void processFilesRemote(List<Readset> readsets, JobContext ctx) throws Un
199205 FastqDumpWrapper wrapper = new FastqDumpWrapper (ctx .getLogger ());
200206 Pair <File , File > files = wrapper .downloadSra (accession , ctx .getOutputDir ());
201207
202- try
208+ File sraLog = new File (expectedFile1 .getParentFile (), FileUtil .makeLegalName ("sraDownload_" + timestamp + ".txt" ));
209+ try (PrintWriter writer = PrintWriters .getPrintWriter (IOUtil .openFileForWriting (sraLog , true )))
203210 {
204211 ctx .getLogger ().info ("Copying file to: " + expectedFile1 .getPath ());
205212 Files .copy (files .first .toPath (), expectedFile1 .toPath ());
206213 ctx .getFileManager ().addIntermediateFile (files .first );
214+ writer .println ("Downloaded " + expectedFile1 .getName () + " from " + accession + " on " + timestamp + ", size: " + FileUtils .byteCountToDisplaySize (FileUtils .sizeOf (expectedFile1 )));
215+
207216 if (expectedFile2 != null )
208217 {
209218 if (files .second == null )
@@ -214,6 +223,7 @@ public void processFilesRemote(List<Readset> readsets, JobContext ctx) throws Un
214223 ctx .getLogger ().info ("Copying file to: " + expectedFile2 .getPath ());
215224 Files .copy (files .second .toPath (), expectedFile2 .toPath ());
216225 ctx .getFileManager ().addIntermediateFile (files .second );
226+ writer .println ("Downloaded " + expectedFile2 .getName () + " from SRA " + accession + " on " + timestamp + ", size: " + FileUtils .byteCountToDisplaySize (FileUtils .sizeOf (expectedFile2 )));
217227 }
218228 }
219229 catch (IOException e )
0 commit comments