Entering edit mode
4.9 years ago
tianshenbio
▴
180
I used the following codes to run multiple files on sortmeRNA but it did not work...Any problem with it?
#!/bin/bash
READ1="$1"
READ2="$2"
BASE=$(basename "${READ1/_1P.fq.gz/}")
echo "Uncompressing FASTQ data of $BASE"
gunzip "$READ1" "$READ2"
READ1="${READ1%.gz}"
READ2="${READ2%.gz}"
echo "Merging pairs of $BASE"
merge-paired-reads.sh "$READ1" "$READ2" "${BASE}_merge.fq"
echo "Running SortMeRNA for $BASE"
sortmerna --ref ./rRNA_databases/silva-bac-16s-id90.fasta,./index/silva-bac-16s-db --reads "${BASE}_merge.fq" --aligned \
"${BASE}_rRNA" --other "${BASE}_clean" --log -a 16 \
-v --paired_in --fastx
echo "Unmerging SortMeRNA filtered pairs for $BASE"
unmerge-paired-reads.sh "${BASE}_clean.fq" \
"${BASE}_clean1.fq" "${BASE}_clean2.fq"
echo "Doing cleanup for $BASE"
gzip "$READ1" "$READ2" "${BASE}_clean1.fq" \
"${BASE}_clean2.fq" "${BASE}_rRNA.fq"
rm "${BASE}_merge.fq" "${BASE}_clean.fq"
##--- END HERE ---
do you have any error messages when you run this script? Please also post the example names for forward and reverse files. Can you print out put from variable: $FILEBASE? where did you define it?@ tianshenbio
Hi! Sorry for the typo, the '$FILEBASE' should be '$BASE'. My files were named as DS_1_1P.fq.gz, DS_1_2P.fq.gz, WS_2_1P.fq.gz... I have different names for 'DS_1_', and '_1P' and '_2P' indicate forward and reverse reads. I tried to execute the script using:
find /path to my original files -name "*.fq.gz" | sort | head -n 32 | while read READ1 do read READ2 bash /path to my script $READ1 $READ2 done
When I started running, the terminal just stuck there and no msg popped up.
basename removes only the extension, not the string. Print / echo base output
Sorry, I didn't get that, could you explain more?
Do values of
$BASE
that you are printing at each step look ok is what @cpad0112 is asking.I think the script did not execute at all...
What is the exact command you are using to run the script (code posted above in a file)? Code above is expecting to get two values
$1
and$2
from command line so it would need to look something like:I mentioned that in my previous response, it was:
find /path to my original files -name "*.fq.gz" | sort | head -n 32 | while read READ1 do read READ2 bash /path to my script.sh $READ1 $READ2 done
Here is setup similar to your case:
My script just has the first part of your script:
If I run your command line then I can correctly grab the filename in
$BASE
variable. So you need to figure out what else is not working in your script after the step where you grab the base file name.Edit: Depending on the size of your data files it may take a while for this analysis to run. You are uncompressing the data files and then doing additional operations on them.
Thank you so much! That's very clear. My script works fine now.
If this works, you only need to edit commands in loop. Remove echo in loop and other places wherever necessary.
output on my local pc is:
Hi, thank you for your suggestion, I tried it and I got this: