Automated file conversions


#1

Hi,

I need help fixing my script to automate multiple file conversions.
I am working in the server so, and i am trying to find a way to convert files automatically
the conversion needs to be made through four formats: sam,bwa, and bcf, and vcf
The files increment at two spots like this
each increment has two file formats: .sai and .fastq

004_001
…2
…3
…4

then*
005_001
…2
…3
…4

I have tried:

Code:

for i in {1…4}
do*
$bwa samse $hg19 $csai $cfas > .sam
done

but it only work with the _001 file all four times.
I have tried setting the end increment to I so instead of _001 its *_00$((i)) to go 1,2,3,4 but its stays at 1.

example of sam conversion

Code:

for i in {1…4}
do*
./bwa samse* /hg19.fa* *_00$((i)).sai _00$((i)).fastq > *_00$((i)).sam
done

I wrote it to run input files with that name and output data to the sam file.*
It works but it converts _001 four time instead of _001 to _004

basically I need to write a script that will automate multiple file conversions
3 file inputs > output 1 file .sam
input .sam file > output .bam file
input bam file > output .bcf file
input .bcf file > output .vcf file


#2

Hi,

If you need to iterate all files try something like:

$ for file in *_00{1..4}.*; do echo $file; done
004_001.fastq
004_001.sai
005_001.fastq
005_001.sai
004_002.fastq
004_002.sai
005_002.fastq
005_002.sai
004_003.fastq
004_003.sai
005_003.fastq
005_003.sai
004_004.fastq
004_004.sai
005_004.fastq
005_004.sai

Otherwise, to get help with you questions please, show example of all files before conversion and after iteration. Be clear with your intentions and avoid * where possible.


#3

#4