Skip to content

Commit 711f0f8

Browse files
committed
Bugfix to SRA restore with single-end data
1 parent dcbb4a9 commit 711f0f8

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

SequenceAnalysis/api-src/org/labkey/api/sequenceanalysis/model/ReadData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ public interface ReadData extends Serializable
6161
String getSra_accession();
6262

6363
boolean isArchived();
64+
65+
boolean isPairedEnd();
6466
}

SequenceAnalysis/src/org/labkey/sequenceanalysis/ReadDataImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,11 @@ public void cacheForRemoteServer()
307307
}
308308
}
309309

310+
@Override
310311
@Transient
311312
public boolean isPairedEnd()
312313
{
313-
return getFile2() != null;
314+
return getFileId2() != null;
314315
}
315316

316317
@Override

SequenceAnalysis/src/org/labkey/sequenceanalysis/pipeline/SequenceAlignmentTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ else if (sraIDs.contains(rd.getSra_accession()))
19411941
RestoreSraDataHandler.FastqDumpWrapper sra = new RestoreSraDataHandler.FastqDumpWrapper(getJob().getLogger());
19421942
if (doneFile.exists())
19431943
{
1944-
rdi.setFile(new File(outDir, rd.getSra_accession() + "_1.fastq.gz"), 1);
1944+
rdi.setFile(new File(outDir, rd.getSra_accession() + (rd.isPairedEnd() ? "_1" : "") + ".fastq.gz"), 1);
19451945
if (rd.getFileId2() != null)
19461946
{
19471947
rdi.setFile(new File(outDir, rd.getSra_accession() + "_2.fastq.gz"), 2);
@@ -1954,7 +1954,7 @@ else if (sraIDs.contains(rd.getSra_accession()))
19541954
outDir.mkdirs();
19551955
}
19561956

1957-
Pair<File, File> downloaded = sra.downloadSra(rd.getSra_accession(), outDir);
1957+
Pair<File, File> downloaded = sra.downloadSra(rd.getSra_accession(), outDir, rd.isPairedEnd());
19581958
rdi.setFile(downloaded.first, 1);
19591959
rdi.setFile(downloaded.second, 2);
19601960

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public void processFilesRemote(List<Readset> readsets, JobContext ctx) throws Un
384384
File expectedFile2 = rd.getFileId2() == null ? null : ctx.getSequenceSupport().getCachedData(rd.getFileId2());
385385

386386
FastqDumpWrapper wrapper = new FastqDumpWrapper(ctx.getLogger());
387-
Pair<File, File> files = wrapper.downloadSra(accession, ctx.getOutputDir());
387+
Pair<File, File> files = wrapper.downloadSra(accession, ctx.getOutputDir(), rd.isPairedEnd());
388388

389389
long lines1 = SequenceUtil.getLineCount(files.first) / 4;
390390
ctx.getJob().getLogger().debug("Reads in " + files.first.getName() + ": " + lines1);
@@ -459,7 +459,7 @@ public FastqDumpWrapper(@Nullable Logger logger)
459459
super(logger);
460460
}
461461

462-
public Pair<File, File> downloadSra(String dataset, File outDir) throws PipelineJobException
462+
public Pair<File, File> downloadSra(String dataset, File outDir, boolean expectPaired) throws PipelineJobException
463463
{
464464
List<String> args = new ArrayList<>();
465465
args.add(getExe().getPath());
@@ -491,7 +491,7 @@ public Pair<File, File> downloadSra(String dataset, File outDir) throws Pipeline
491491

492492
List<File> files = new ArrayList<>(Arrays.asList(Objects.requireNonNull(outDir.listFiles((dir, name) -> name.startsWith(dataset)))));
493493

494-
File file1 = new File(outDir, dataset + "_1.fastq");
494+
File file1 = new File(outDir, dataset + (expectPaired ? "_1" : "") + ".fastq");
495495
if (!file1.exists())
496496
{
497497
throw new PipelineJobException("Missing file: " + file1.getPath());
@@ -500,7 +500,12 @@ public Pair<File, File> downloadSra(String dataset, File outDir) throws Pipeline
500500
files.remove(file1);
501501

502502
File file2 = new File(outDir, dataset + "_2.fastq");
503-
if (!file2.exists())
503+
if (expectPaired & !file2.exists())
504+
{
505+
throw new PipelineJobException("Missing file: " + file2.getPath());
506+
}
507+
508+
if (!expectPaired)
504509
{
505510
file2 = null;
506511
}

0 commit comments

Comments
 (0)