The current GATK version is 3.8-0
Examples: Monday, today, last week, Mar 26, 3/26/04

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Get notifications!

You can opt in to receive email notifications, for example when your questions get answered or when there are new announcements, by following the instructions given here.

Got a problem?

1. Search using the upper-right search box, e.g. using the error message.
2. Try the latest version of tools.
3. Include tool and Java versions.
4. Tell us whether you are following GATK Best Practices.
5. Include relevant details, e.g. platform, DNA- or RNA-Seq, WES (+capture kit) or WGS (PCR-free or PCR+), paired- or single-end, read length, expected average coverage, somatic data, etc.
6. For tool errors, include the error stacktrace as well as the exact command.
7. For format issues, include the result of running ValidateSamFile for BAMs or ValidateVariants for VCFs.
8. For weird results, include an illustrative example, e.g. attach IGV screenshots according to Article#5484.
9. For a seeming variant that is uncalled, include results of following Article#1235.

Did we ask for a bug report?

Then follow instructions in Article#1894.

Formatting tip!

Wrap blocks of code, error messages and BAM/VCF snippets--especially content with hashes (#)--with lines with three backticks ( ``` ) each to make a code block as demonstrated here.

Jump to another community
Download the latest Picard release at
GATK version 4.beta.3 (i.e. the third beta release) is out. See the GATK4 beta page for download and details.

Picard RevertSam and OUTPUT_BY_READGROUP does not allow specify output files

I am using a pipeline with as input bam and cram files. The first step of this pipeline is RevertSam combined with the option OUTPUT_BY_READGROUP and I walked into the fact that it is impossible to specify your output type of your files and is the same as the input file. (See and 278-288) . Since developing two pipelines is not quite time efficient (as is working hours) and converting the cram files into bam files is also not efficient (cpu/io wise) I will focus on a bam only pipeline and specify the output type.

The default is a bam as output and I hide the cram file extension by using the following construct:

cat sample.cram |java -jar picard.jar RevertSam TMP_DIR=. I=/dev/stdin OUTPUT_BY_READGROUP=true SORT_ORDER=queryname O=revertsam COMPRESSION_LEVEL=1 REFERENCE_SEQUENCE=ref.fasta

This smells like a fishy hack to me, but it seems to work. Is there a better/faster/stronger/less hackerish way to do this?


Best Answer


  • SheilaSheila Broad InstituteMember, Broadie, Moderator


    Are you using the latest version of Picard? Can you post the exact command you ran? According to the documentation, RevertSam can output any type of file as long as the extension is properly specified.


  • maartenSmaartenS AmsterdamMember

    I'm using picard 2.60:

    The command's I ran are:
    mkdir revertsam
    java -jar picard.jar RevertSam TMP_DIR=. I=sample.cram OUTPUT_BY_READGROUP=true SORT_ORDER=queryname O=revertsam COMPRESSION_LEVEL=1 REFERENCE_SEQUENCE=ref.fasta

    Because the input is cram the output is also cram:

    The behaviour in line with the documentation:

    """Will output a BAM/SAM file per read group. By default, all outputs will be in BAM format. However, a SAM file will be produced instead for any read group mapped in OUTPUT_MAP to a path ending with '.sam'. A CRAM file will be produced for any read group mapped to a path ending with '.cram'. """

    However, the output file specified with "=O" must be a directory and not filename when OUTPUT_BY_READGROUP is used.

  • SheilaSheila Broad InstituteMember, Broadie, Moderator


    I think if you specify O=revertsam.bam, you should get a BAM file.


  • maartenSmaartenS AmsterdamMember

    No, it does not:
    it gives the following output:

    When OUTPUT_BY_READGROUP=true and OUTPUT is provided, it must be a directory: revertsam.bam

    Which is in line with the documentation.

  • maartenSmaartenS AmsterdamMember
    edited September 2016

    @Geraldine_VdAuwera I will put a feature request at the Picard github repo. I will post the link to the feature request when I made the request.

Sign In or Register to comment.