If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Please use ADD COMMENT or ADD REPLY to answer to previous reactions, as such this thread remains logically structured and easy to follow. I have now moved your reaction but as you can see it's not optimal.
Adding an answer should only be used for providing a solution to the question asked.
Do you men to say, you want to do mapping of different sample against your reference genome ?
You can use following script for mapping multiple sample using bwa. (Note: save the below script in .sh format (say "mapping.sh") and make sure that are no other fastq file rather then your sample should be there in your working directory)
I am very new to bash but think this code is exactly what I need (same problem).
Would it be possible to step through what the for loop is doing? Thank you
Follow along using the numbers below as line numbers to the script above.
Counting number of files that end in *.fastq. If your files have different endings then substitute accordingly.
Assigning the names of the files to an array called arr.
Just printing a message to screen and append to log file called map.log.
Just printing a message to screen and append to log file called map.log.
A for loop to step through the array taking two file names at a time (this is a paired-end dataset so forward and reverse pair, will need to change depending on your use case) until you take all elements from array. Array elements start at position [0].
sample_name extracts the actual name of the sample (stuff before first _ e.g. Sample1 from Sample1_fastq)
Printing the name you are working with to screen with echo
Printing the actula command you are working with. Name of output file created using $sample_name as $sample_name.sam.
But then bwa mem runs for two pairs of input files in the folder but output only one file named sample.bam
However, I am expecting two output files, A1.bam and B1.bam
But the same script runs if the same samples are in the directory itself rather than a folder in the same directory. But I want to have my input files in the folder and it does not work.
Thanks Suraj. Yes. This what I mean. It is working now.
If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Please use
ADD COMMENT
orADD REPLY
to answer to previous reactions, as such this thread remains logically structured and easy to follow. I have now moved your reaction but as you can see it's not optimal. Adding an answer should only be used for providing a solution to the question asked.