Question: Looping over vcf files
0
gravatar for paolo002
2.4 years ago by
paolo002160
paolo002160 wrote:

Hi I have a list of various vcf files for different human populations in a directory. pop1.vcf pop2.vcf pop3.vcf pop4.vcf Usually, if I want to do some operation on those files I loop over in bash shell. Example:

for file in /home/users/vcf/*.vcf;
do plink --vcf ${file} --recode -out ${file}.flt.vcf;
done

However, now let's say if I have other 4 files for different populations :

pop5.vcf pop6.vcf pop7.vcf pop8.vcf

I would like to do some operation such as merge for instance for each pair of file in single combination and not over all the possible combination, and third file for each pair will be generated as output:

pop1.vcf with pop5.vcf pop2.vcf with pop6.vcf and so on.

Other times I have this second set of files in different extension. Such as :

pop1.vcf with pop5.bed pop2.vcf with pop6.bed and so on.

How to write a loop with iterates over pair of files doing some kind of operation?

Any help, highly appreciated, thanks

bash linux • 1.1k views
ADD COMMENTlink modified 2.3 years ago by zx87549.9k • written 2.4 years ago by paolo002160

Is there a constant relationship between the file pairs? I.e. is the offset between numbers always the same (i.e 1 with 3, 2 with 4, 3 with 6 etc?).

If the pairings are arbitrary, there's no way to do it without first mapping the numbers to one another

ADD REPLYlink written 2.3 years ago by Joe19k
1
gravatar for Pierre Lindenbaum
2.4 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum134k wrote:
 for F1 in *.vcf.gz; do for F2 in *.vcf.gz; do if [[ "$F1" < "$F2" ]]; then echo $F1 $F2; fi; done ; done
ADD COMMENTlink written 2.4 years ago by Pierre Lindenbaum134k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1868 users visited in the last hour
_