Skip to content

Commit e50b12c

Browse files
committed
Better support readsets created directly from SRA
1 parent f75ffaa commit e50b12c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/RestoreSraDataHandler.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.labkey.sequenceanalysis.SequenceAnalysisSchema;
4848
import org.labkey.sequenceanalysis.pipeline.ReadsetCreationTask;
4949
import org.labkey.sequenceanalysis.pipeline.SequenceNormalizationTask;
50+
import org.labkey.sequenceanalysis.pipeline.SequenceTaskHelper;
5051
import org.labkey.sequenceanalysis.util.SequenceUtil;
5152

5253
import java.io.File;
@@ -299,6 +300,12 @@ public void complete(PipelineJob job, List<Readset> readsets, List<SequenceOutpu
299300
toUpdate.put("archived", false);
300301
toUpdate.put("container", rd.getContainer());
301302

303+
if (rd.getRunId() == null)
304+
{
305+
Integer runId = SequenceTaskHelper.getExpRunIdForJob(job);
306+
toUpdate.put("runid", runId);
307+
}
308+
302309
rows.add(toUpdate);
303310

304311
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("readset"), rs.getRowId());
@@ -383,12 +390,18 @@ public void processFilesRemote(List<Readset> readsets, JobContext ctx) throws Un
383390
File expectedFile1 = ctx.getSequenceSupport().getCachedData(rd.getFileId1());
384391
File expectedFile2 = rd.getFileId2() == null ? null : ctx.getSequenceSupport().getCachedData(rd.getFileId2());
385392

393+
if (!expectedFile1.getParentFile().exists())
394+
{
395+
ctx.getLogger().info("Creating folder: " + expectedFile1.getParentFile().getPath());
396+
expectedFile1.getParentFile().mkdirs();
397+
}
398+
386399
FastqDumpWrapper wrapper = new FastqDumpWrapper(ctx.getLogger());
387400
Pair<File, File> files = wrapper.downloadSra(accession, ctx.getOutputDir(), rd.isPairedEnd(), false);
388401

389402
long lines1 = SequenceUtil.getLineCount(files.first) / 4;
390403
ctx.getJob().getLogger().debug("Reads in " + files.first.getName() + ": " + lines1);
391-
if (lines1 != accessionToReads.get(accession))
404+
if (accessionToReads.containsKey(accession) && lines1 != accessionToReads.get(accession))
392405
{
393406
throw new PipelineJobException("Reads found in file, " + lines1 + ", does not match expected: " + accessionToReads.get(accession) + " for file: " + files.first.getPath());
394407
}
@@ -397,7 +410,7 @@ public void processFilesRemote(List<Readset> readsets, JobContext ctx) throws Un
397410
{
398411
long lines2 = SequenceUtil.getLineCount(files.second) / 4;
399412
ctx.getJob().getLogger().debug("Reads in " + files.second.getName() + ": " + lines2);
400-
if (lines2 != accessionToReads.get(accession))
413+
if (accessionToReads.containsKey(accession) && lines2 != accessionToReads.get(accession))
401414
{
402415
throw new PipelineJobException("Reads found in file, " + lines2 + ", does not match expected: " + accessionToReads.get(accession) + " for file: " + files.second.getPath());
403416
}

0 commit comments

Comments
 (0)