Question: Can I get AddOrReplaceReadGroups working for multiple files?
0
gravatar for James Reeve
17 months ago by
James Reeve100
Canada
James Reeve100 wrote:

I have a dataset of 81 samples that are missing read group information. This leads to problems when trying to use GATK commands. I've found picard tools' AddOrReplaceReadGroups to be a helpful tool for adding read group to a SAM file. But I'm having trouble trying to loop through this command for all my files.

I've been able to come up with this, but there seems to be an issue with my notation in my variables;

while read f1
do 
  FileName=$(echo $f1 | cut -d"," -f1)
  SampleID=$(echo $f1 | cut -d"," -f3)
  RowNum=$(grep -n $FileName.bam)
  java -jar picard.jar AddOrReplaceReadGroups \
     I=$FileName.bam \
     O=$FileName"_sort.bam" \
     SORT_ORDER=coordinate \
     RGID=$SampleID \
     RGLB=WGS \
     RGPL=illumina \
     RGPU=$RowNum \
     RGSM=$FileName
done < file_with_sample_information.csv

Note: the input file file_with_sample_information.csv has 4 columns, the 1st has the sample name and the 3rd has the database (ENA) ascension number.

How can I get this too work? I'd like to avoid manually doing this for 81 files.

bash picard tools • 690 views
ADD COMMENTlink modified 17 months ago by Barry Digby310 • written 17 months ago by James Reeve100
2
grep -n $FileName.bam

will not produce anything. You're grepping stdin

ADD REPLYlink written 17 months ago by Pierre Lindenbaum127k
2
gravatar for Barry Digby
17 months ago by
Barry Digby310
National University of Ireland, Galway
Barry Digby310 wrote:
while read a b c d; do 
...
...
done < file_with_sample_information.csv

$a is column 1, $b is column 2 and so on.

Just separate a b c d with a space.

Is it trouble assigning variables to filenames? or trouble assigning multiple variables (a, b, c, d)..? Show me the first line of your file

ADD COMMENTlink modified 17 months ago • written 17 months ago by Barry Digby310

I was trying to assign multiple variables. I figured it out from your example, thanks.

ADD REPLYlink written 17 months ago by James Reeve100
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1821 users visited in the last hour