Skip to content

Commit 5550155

Browse files
committed
Improve validation for PCA/per-batch code
1 parent 6729c1c commit 5550155

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/variant/PlinkPcaStep.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.apache.commons.lang3.StringUtils;
99
import org.apache.logging.log4j.Logger;
1010
import org.json.JSONObject;
11+
import org.labkey.api.data.CompareType;
1112
import org.labkey.api.data.Container;
1213
import org.labkey.api.data.SimpleFilter;
1314
import org.labkey.api.data.TableSelector;
@@ -201,6 +202,7 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
201202
getPipelineCtx().getLogger().info("Writing Sample Map");
202203
for (SequenceOutputFile so : inputFiles)
203204
{
205+
Set<String> duplicates = new HashSet<>();
204206
try (VCFFileReader reader = new VCFFileReader(so.getFile()))
205207
{
206208
VCFHeader header = reader.getFileHeader();
@@ -213,17 +215,22 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
213215
{
214216
// Find readset:
215217
Container targetContainer = getPipelineCtx().getJob().getContainer().isWorkbook() ? getPipelineCtx().getJob().getContainer().getParent() : getPipelineCtx().getJob().getContainer();
216-
Set<String> applications = new HashSet<>(new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_READSETS), PageFlowUtil.set("application"), new SimpleFilter(FieldKey.fromString("name"), sample), null).getArrayList(String.class));
218+
Set<String> applications = new HashSet<>(new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_READSETS), PageFlowUtil.set("application"), new SimpleFilter(FieldKey.fromString("name"), sample).addCondition(FieldKey.fromString("status"), null, CompareType.ISBLANK), null).getArrayList(String.class));
217219
if (applications.size() == 1)
218220
{
219221
writer.println(sample + "\t" + applications.iterator().next());
220222
}
221223
else
222224
{
223-
throw new PipelineJobException("More than one readset found with name: " + sample);
225+
duplicates.add(sample);
224226
}
225227
}
226228
}
229+
230+
if (!duplicates.isEmpty())
231+
{
232+
throw new PipelineJobException("More than one readset with the given name found for the following samples: " + StringUtils.join(duplicates, ","));
233+
}
227234
}
228235
}
229236
catch (IOException e)

0 commit comments

Comments
 (0)