![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
multiplex few variants in hundreds of samples | fadista | Bioinformatics | 2 | 12-02-2011 01:10 AM |
IQ run | eoh001 | SOLiD | 1 | 07-05-2011 07:07 AM |
pileup output different using Maq and Samtools commands | mr_boourns | Bioinformatics | 1 | 03-31-2011 04:05 AM |
25 bp/frag run vs 50 bp/frag run regarding N2S ratio and cost efficiency | smallcreek | SOLiD | 1 | 12-02-2009 05:47 AM |
Error-correcting barcoded primers for pyrosequencing hundreds of samples in multiplex | ECO | Literature Watch | 0 | 02-12-2008 11:30 PM |
![]() |
|
Thread Tools |
![]() |
#1 |
Member
Location: boston Join Date: Jun 2011
Posts: 27
|
![]()
Hi guys
I'm analyzing some high-coverage trio data. So Need to run BWA for hundreds of fastq.gz files. Obviously I should write some script to finish such task without waiting and typing in hundreds of commands one by one. But as a beginner without coding experience, I don't know how to do. For example, I just put bwa aln -t 24 index file1>1.sam bwa aln -t 24 index file2>2.sam bwa aln -t 24 index file3>3.sam ............... .............. into the script, and run it..........and it doesn't work at all. I know I must miss sth., say, the pathway for fastq files. anyone can give any pattern about such script of executing multiple jobs? thx |
![]() |
![]() |
![]() |
#2 |
Member
Location: Berkeley Join Date: Feb 2011
Posts: 30
|
![]()
How about giving us the error message that you're getting? What if you just run one of them in isolation? It's hard to guess what the problem is as we have no idea what your environment and files are.
|
![]() |
![]() |
![]() |
#3 |
Senior Member
Location: Sydney Join Date: Feb 2011
Posts: 149
|
![]()
Without having to learn perl or other languauge, the simplest but probably very clunky way of doing it is to use a shell script.
Create a text file (e.g. with gedit would be simplest), and name it xxx.sh (where .sh stands for shell). In the file at the top, put in: Code:
#!/bin/bash echo `bwa aln -t 24 index file1>1.sam` echo `bwa aln -t 24 index file2>2.sam` echo `bwa aln -t 24 index file3>3.sam` ... exit This will execute each line as step by step commands. Make sure the quotes is the one generated by the tilde ('~') key at the top left of your keyboard. Of course typing all the lines would be a chore, so you might want to use a spreadsheet to fill in the increments. One last thing. After you've created this file, you need to give it permission to be executable. In the terminal, cd to where this file is created, and type: Code:
chmod +x xxx.sh Code:
nohup ./xxx.sh > log.txt I understand your position so I've tried my best to help out here (not sure what the general rule here about writing code is for other people, but...). Try googling about shell scripts, and I'm sure you'll pick it up quickly and improve the above too. Last edited by Kennels; 06-14-2011 at 05:19 PM. |
![]() |
![]() |
![]() |
#4 |
Member
Location: boston Join Date: Jun 2011
Posts: 27
|
![]()
Many many thanks Kennels!!!
Yeah, I just made the spreadsheet, actually with 800 fastq files. And the shell script works quite well! btw, can you give any clue about writing Perl to finish such task? I think I can read and understand some Perl script, but just cannot write by myself. thx a lot! |
![]() |
![]() |
![]() |
#5 |
Senior Member
Location: Sydney Join Date: Feb 2011
Posts: 149
|
![]()
In perl, you can probably do it with 'for' or 'while' conditional loops using counters, and use 'filehandles' for input/output files, but I'm still a novice at best.
As there is no simple answer to your request other than to sit down and learn it from scratch, I would recommend buying 'Beginning Perl for Bioinformatics' by James Tisdall (O'Reilly books). Even reading the first few chapters is enough to get you through many common tasks. It sure did for me, and I'm not even finished with the book. Good luck! |
![]() |
![]() |
![]() |
#6 |
Member
Location: Berkeley Join Date: Feb 2011
Posts: 30
|
![]()
I hadn't understood the question was about the script, not bwa.
I haven't read that book but I've heard good things about it. You can do it in the shell fairly easily too: Code:
for i in file* do bwa aln -t 24 index $i>$i.sam done Code:
ls file* | xargs -n1 -P24 -I{} bwa aln index {}>{}.sam Both of the examples above have a longer name for the sam file. You if you prefer your original naming scheme, you can use something like: Code:
for i in file*.sam do echo mv $i `echo $i | sed -e 's/file//'` done |
![]() |
![]() |
![]() |
Thread Tools | |
|
|