lindenb / jvarkit

Java utilities for Bioinformatics
https://jvarkit.readthedocs.io/
Other
482 stars 133 forks source link

FindAllCoverageAtPosition works only when the file name comes from standard input #80

Closed ialbert closed 7 years ago

ialbert commented 7 years ago

The documentation states that the usage is:

Usage: findallcoverageatposition [options] Files

but for me it seems to only work when the file is specified from the stdin:

echo RK15_S15_corrected.bam | java -jar ~/src/jvarkit/dist/findallcoverageatposition.jar -p "chr18:34314650"

produces:

[INFO][FindAllCoverageAtPosition]number of mutations 1
[INFO][FindAllCoverageAtPosition]Reading from stdin
#File   CHROM   POS SAMPLE  DEPTH   M   I   D   N   S   H   P   EQ  X   Base(A) Base(C) Base(G) Base(T) Base(N) Base(^) Base(-)
RK15_S15_corrected.bam  chr18   34314650    RK15_S15    468123  468123  23  539 0   840 0   0   0   0   57  4   468031  31  0   23  539

whereas:

java -jar ~/src/jvarkit/dist/findallcoverageatposition.jar -p "chr18:34314650" RK15_S15_corrected.bam

produces an empty line:

[INFO][FindAllCoverageAtPosition]number of mutations 1
[INFO][FindAllCoverageAtPosition]Reading from RK15_S15_corrected.bam
#File   CHROM   POS SAMPLE  DEPTH   M   I   D   N   S   H   P   EQ  X   Base(A) Base(C) Base(G) Base(T) Base(N) Base(^) Base(-)

I believe that the problem is that the r=IOUtils.openURIForBufferedReading(filename); in

https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/FindAllCoverageAtPosition.java#L504

returns the contents of the file, whereas the scan that uses the iterator expects the iterator to return the name of the file rather than the contents of it

https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/FindAllCoverageAtPosition.java#L227

lindenb commented 7 years ago

Hi @ialbert , yes I should add this in the documentation, the input file is a list of path to BAM files.


echo RK15_S15_corrected.bam > input.list
java -jar ~/src/jvarkit/dist/findallcoverageatposition.jar -p "chr18:34314650"  input.list

that's why I usually use 'find' for this tool.

ialbert commented 7 years ago

Ah ok, I got it.