Skip to content

SAM/BAM file from stdin #177

@Jelinek-J

Description

@Jelinek-J

Hi,

it is possible to read FASTQ file from standard input using zcat test.fastq.gz | fastqc stdin. However I'm not able to read SAM/BAM file from standard input this way (useful e.g. if there are multialignments) samtools view -F 256 -h test.bam | fastqc stdin produces a following error:

null
Failed to process stdin
uk.ac.babraham.FastQC.Sequence.SequenceFormatException: Midline '@SQ    SN:ENST00000000001      LN:1000' didn't start with '+' at 3
        at uk.ac.babraham.FastQC.Sequence.FastQFile.readNext(FastQFile.java:179)
        at uk.ac.babraham.FastQC.Sequence.FastQFile.<init>(FastQFile.java:93)
        at uk.ac.babraham.FastQC.Sequence.SequenceFactory.getSequenceFile(SequenceFactory.java:106)
        at uk.ac.babraham.FastQC.Sequence.SequenceFactory.getSequenceFile(SequenceFactory.java:62)
        at uk.ac.babraham.FastQC.Analysis.OfflineRunner.processFile(OfflineRunner.java:163)
        at uk.ac.babraham.FastQC.Analysis.OfflineRunner.<init>(OfflineRunner.java:125)
        at uk.ac.babraham.FastQC.FastQCApplication.main(FastQCApplication.java:316)

Apparently automatic file format detection does not work with standard input and it tries to parse it as a FASTQ file. But forcing the correct format (samtools view -F 256 -h test.bam | fastqc -f sam stdin) will just produce a different error.:

Failed to process stdin
java.io.FileNotFoundException: stdin (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:152)
        at uk.ac.babraham.FastQC.Sequence.BAMFile.<init>(BAMFile.java:62)
        at uk.ac.babraham.FastQC.Sequence.SequenceFactory.getSequenceFile(SequenceFactory.java:81)
        at uk.ac.babraham.FastQC.Sequence.SequenceFactory.getSequenceFile(SequenceFactory.java:62)
        at uk.ac.babraham.FastQC.Analysis.OfflineRunner.processFile(OfflineRunner.java:163)
        at uk.ac.babraham.FastQC.Analysis.OfflineRunner.<init>(OfflineRunner.java:125)
        at uk.ac.babraham.FastQC.FastQCApplication.main(FastQCApplication.java:316)

So it looks like specifying the format turns off the special handling of the 'stdin' keyword.

$ fastqc -v
FastQC v0.12.1

Is it intentional that only FASTQ files are supported from stdin, or is there a plan to add support for SAM/BAM files as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions