A question about shell scripting: getting multiple input files for an application
Hi everyone,
I'm new to linux and shell scripting and am having particular trouble figuring out how exactly to approach/script the following that I wish to do. Any help would be much, much appreciated. :) I am running an application called QuantiSNP (http://groups.google.co.uk/group/qua...uantisnp-usage). The binary file is "quantisnp2", called upon in the "run_quantisnp2.sh" supplied by the authors. I am only able to run the application for single file processing (e.g. 1 input file for 1 sample; I can't run the batch file processing because I don't have the necessary BeadStudio report files, which has different formatting for the input files). The difficulty is that I have 300 samples (300 unique sample IDs) and 3 input files for each sample for a total of 900 runs of this application. I am wondering how would I be able to automate this process as a shell script instead of basically manually changing the sample ID and respective input files every time a run completes? I bolded the single file processing shell script command line options below that need to be changed for each sample/input single file processing run. The command line option "--sampleid" is for the name given to the processed output files corresponding to the sample of interest and there are 3 input files for each sample. /home2/jason/QuantiSNP/quantisnp/linux64/run_quantisnp2.sh /home2/jason/QuantiSNP/MCR/v79/ --config /home2/jason/QuantiSNP/quantisnp/config/params.dat --levels /home2/jason/QuantiSNP/quantisnp/config/levels-affy.dat --outdir /home2/jason/QuantiSNP/quantisnp_out/ --sampleid sample1 --gender female --input-files /home2/jason/files/sample1_input.txt ------------- Note that each sample has 3 input files, for a total of 3 runs of "quantisnp2" for each sample. e.g. SAMPLEID INFILE sample1 /home2/jason/files/sample1_input.txt sample1 /home2/jason/files/sample1_input2.txt sample1 /home2/jason/files/sample1_input3.txt sample2 /home2/jason/files/sample2_input.txt sample2 /home2/jason/files/sample2_input2.txt sample2 /home2/jason/files/sample2_input3.txt ...etc. ------------- Thanks again! Please feel free to let me know if anything I wrote above needs clarification. |
Code:
While read line; do run_quantisnp2.sh ... -sampleid `echo $line | awk '{ print $1 }'` --input-files `echo $line | awk '{ print $2 }'`; done < SAMPLEID.INFILE |
Well, the actual iteration can be done with a simple loop. The big question is making sure you're using the right files in the loop at the right time.
Could you break it down in just a bit more detail? What is the exact sequence of files that need to be processed? Is there any variability in the filenames or locations? Do the names always correspond to each other? Finally, please use [code][/code] tags around the contents of scripts and text files, to preserve formatting and improve readability. |
Assuming all the files are int he same directory (ie /home2/jason/files/):
Code:
#!/bin/bash |
Thanks quanta, David, and grail for your replies.
Code:
/home2/jason/QuantiSNP/quantisnp/linux64/run_quantisnp2.sh /home2/jason/QuantiSNP/MCR/v79/ --config /home2/jason/QuantiSNP/quantisnp/config/params.dat --levels /home2/jason/QuantiSNP/quantisnp/config/levels-affy.dat --outdir /home2/jason/QuantiSNP/quantisnp_out/ --sampleid sample1 --gender female --input-files /home2/jason/files/sample1_input.txt Because the text files names do not correspond exactly to the sample IDs, would it be better if I create a text file that lists the sample IDs and their corresponding input file and work this into the shell script somehow? (I hope this isn't too confusing) Thanks! I will look at the codes you guys provided in more detail right now. :) Quote:
|
Hello again,
I ran grail's code above. For some reason it is not outputting the files correctly (e.g. nothing in the folder defined in --outdir). From the output log for a processed file: Quote:
However, when I just run a single file only (original commands), the output is the following: Quote:
Help will be much appreciated. Thank you very much! |
yeah my bad there :redface:
Forgot that the path would still be in front of filename. Give this a whirl: Code:
#!/bin/bash If it looks correct then remove the echo and the quotes. |
Hi grail, thanks for the code! It works perfectly now. :)
|
All times are GMT -5. The time now is 10:55 PM. |