Skip to content

Commit

Permalink
Add missing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Mar 14, 2024
1 parent d0779f9 commit 5a6e040
Showing 1 changed file with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.concurrent.Callable;

import genepi.genomic.utils.commands.csv.region.DbSnpIndex;
import genepi.genomic.utils.commands.csv.region.GeneIndex;
import genepi.genomic.utils.commands.csv.region.GenomicRegion;
import genepi.io.text.LineReader;
import genepi.io.text.LineWriter;
Expand All @@ -17,6 +19,15 @@ public class CsvToBedCommand implements Callable<Integer> {
@Option(names = "--output", description = "output bed file", required = true)
private String output;

@Option(names = "--build", description = "genome build", required = true)
private String build = "hg19";

@Option(names = "--genes", description = "gene index file", required = false)
private String genes = null;

@Option(names = "--dbsnp", description = "dbsnp index file", required = false)
private String dbsnp = null;

public void setInput(String input) {
this.input = input;
}
Expand All @@ -25,19 +36,44 @@ public void setOutput(String output) {
this.output = output;
}

public void setGenes(String genes) {
this.genes = genes;
}

public void setBuild(String build) {
this.build = build;
}

public void setDbSnp(String dbsnp) {
this.dbsnp = dbsnp;
}

@Override
public Integer call() throws Exception {

assert (input != null);
assert (output != null);

LineReader reader = new LineReader(input);
if (genes != null) {
GeneIndex.load(genes, build);
}

if (dbsnp != null) {
DbSnpIndex.setFilename(dbsnp);
}

LineWriter writer = new LineWriter(output);
LineReader reader = new LineReader(input);

while (reader.next()) {
String line = reader.get();
GenomicRegion region = new GenomicRegion().parse(line);
writer.write(region.toBedFormat());
try {
GenomicRegion region = GenomicRegion.parse(line.trim(), build);
writer.write(region.toBedFormat());
} catch (Exception e) {
System.out.println("Error processing query: '" + line + "': " + e.getMessage());
return 1;
}
}

reader.close();
Expand Down

0 comments on commit 5a6e040

Please sign in to comment.