Skip to content

Commit

Permalink
analysis: fix try-catch issues, #TASK-4144
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Apr 4, 2023
1 parent d36b6cd commit 9f3ca93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ refGenomePath, new FastaSequenceIndex(new File(base + ".fai")),
}
}
}

} catch (IOException | CatalogException | ToolException | StorageEngineException e) {
throw new ToolExecutorException(e);
}
Expand Down Expand Up @@ -311,11 +310,11 @@ public void computeSignatureCatalogueSV() throws ToolExecutorException {
throw new ToolExecutorException(e);
}

Map<String, Integer> countMap = new HashMap<>();
try (BufferedReader br = FileUtils.newBufferedReader(clusteredFile.toPath())) {
// Skip header line
// chrom1 start1 end1 chrom2 start2 end2 length type sample id is.clustered
// 0 1 2 3 4 5 6 7 8 9 10
Map<String, Integer> countMap = new HashMap<>();
// Skip first line
String line = br.readLine();
while ((line = br.readLine()) != null) {
Expand All @@ -338,30 +337,36 @@ public void computeSignatureCatalogueSV() throws ToolExecutorException {
countMap.put(key, 1);
}
}
} catch (IOException e) {
throw new ToolExecutorException(e);
}

// Build teh genome context counts object for SV
List<Signature.GenomeContextCount> genomeContextCounts = new LinkedList<>();
for (String clustered: new LinkedList<>(Arrays.asList(CLUSTERED, NON_CLUSTERED))) {
for (String type: new LinkedList<>(Arrays.asList(TYPE_DEL, TYPE_TDS, TYPE_INV))) {
for (String length : new LinkedList<>(Arrays.asList(LENGTH_1_10Kb, LENGTH_10Kb_100Kb, LENGTH_100Kb_1Mb, LENGTH_1Mb_10Mb,
LENGTH_10Mb))) {
String key = clustered + "_" + type + "_" + length;
genomeContextCounts.add(new Signature.GenomeContextCount(key, countMap.containsKey(key) ? countMap.get(key) : 0));
}
// Build teh genome context counts object for SV
List<Signature.GenomeContextCount> genomeContextCounts = new LinkedList<>();
for (String clustered: new LinkedList<>(Arrays.asList(CLUSTERED, NON_CLUSTERED))) {
for (String type: new LinkedList<>(Arrays.asList(TYPE_DEL, TYPE_TDS, TYPE_INV))) {
for (String length : new LinkedList<>(Arrays.asList(LENGTH_1_10Kb, LENGTH_10Kb_100Kb, LENGTH_100Kb_1Mb, LENGTH_1Mb_10Mb,
LENGTH_10Mb))) {
String key = clustered + "_" + type + "_" + length;
genomeContextCounts.add(new Signature.GenomeContextCount(key, countMap.containsKey(key) ? countMap.get(key) : 0));
}
String key = clustered + "_" + TYPE_TRANS;
genomeContextCounts.add(new Signature.GenomeContextCount(key, countMap.containsKey(key) ? countMap.get(key) : 0));
}
String key = clustered + "_" + TYPE_TRANS;
genomeContextCounts.add(new Signature.GenomeContextCount(key, countMap.containsKey(key) ? countMap.get(key) : 0));
}

// Write catalogue file from the genome context counts
PrintWriter pw = new PrintWriter(getOutDir().resolve(CATALOGUES_FILENAME_DEFAULT).toFile());
// Write catalogue file from the genome context counts
try (PrintWriter pw = new PrintWriter(getOutDir().resolve(CATALOGUES_FILENAME_DEFAULT).toFile())) {
pw.write(query.getString(VariantQueryParam.SAMPLE.key()));
pw.write("\n");
for (Signature.GenomeContextCount counts : genomeContextCounts) {
pw.write(counts.getContext() + "\t" + counts.getTotal() + "\n");
}
pw.close();
} catch (IOException e) {
throw new ToolExecutorException(e);
}

try {
Signature signature = new Signature()
.setId(getQueryId())
.setDescription(getQueryDescription())
Expand Down Expand Up @@ -431,7 +436,11 @@ private File computeClusteredFile(Query query, QueryOptions queryOptions) throws
}
}
}
} catch (Exception e) {
throw new ToolException(e);
}

try {
// Build command line to run R script via docker image
// Input binding
List<AbstractMap.SimpleEntry<String, String>> inputBindings = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ public void testMutationalSignatureCatalogueSV() throws Exception {
VariantQuery query = new VariantQuery()
.sample(cancer_sample)
.type(VariantType.SV.name())
.file("AR2.10039966-01T_vs_AR2.10039966-01G.annot.brass.vcf.gz");
//.fileData("AR2.10039966-01T_vs_AR2.10039966-01G.annot.brass.vcf.gz:BAS>=0;BKDIST>=-1")
//.region("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y")
//.file("AR2.10039966-01T_vs_AR2.10039966-01G.annot.brass.vcf.gz");
.fileData("AR2.10039966-01T_vs_AR2.10039966-01G.annot.brass.vcf.gz:BAS>=0;BKDIST>=-1")
.region("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y");

//https://ws.opencb.org/opencga-test/webservices/rest/v2/analysis/variant/mutationalSignature/query
// ?study=serena@cancer38:test38
Expand Down

0 comments on commit 9f3ca93

Please sign in to comment.