This is a test version of Biostars. For the public version, visit https://www.biostars.org.
AddOrReplaceReadGroups error -

I want to do a for loop around the picard tool, AddOrReplaceReadGroups, but I get an error that has something to do with my input and output paths (I think). Can someone tell me where I went wrong with this:

# pwd: /Users/phylofun/Downloads/project

for i in mapping/*-pe.bam;
do
    java -jar ~/miniconda2/jar/AddOrReplaceReadGroups.jar \
    I="$i" \
    SORT_ORDER=coordinate \
    RGPL=illumina \
    RGPU=D109LACXX \
    RGLB=Lib1 \
    RGID="${i%-pe.bam}" \
    RGSM="${i%-pe.bam}" \
    VALIDATION_STRINGENCY=LENIENT \
    O=picard/"${i%-pe.bam}-pe-RG.bam"
done

error: Cannot write file: /Users/phylofun/Downloads/project/picard/mapping/sample1-pe-RG.bam. Neither file nor parent directory exist.
picard

1 answer

Your input files are coming from the ./mapping/ directory.

Your output path is specified as ./picard/mapping/ directory. However, files can't be written there if that folder doesn't exist.

Try running mkdir ./picard/mapping and then running the script again. Or change your output file names to not be nested under ./picard so that they use the existing ./mapping folder.

Hope that helps!

Welcome to Biostars and thank you for the contribution! Please use the formatting bar (especially the code option) to present your post better. You can use backticks (`text` becomes text) for inline code, or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

Log in to answer this question.