![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
fastq-dump on SRA files | harlock0083 | Bioinformatics | 15 | 01-25-2022 01:49 AM |
merging fastq files | shilo | Illumina/Solexa | 8 | 07-06-2016 01:15 PM |
How to convert old SOLEXA files to fastq? | sameet | Illumina/Solexa | 3 | 08-19-2013 05:44 PM |
manipulate sequences in Fastq files | lisann_5 | Bioinformatics | 4 | 10-25-2012 04:24 AM |
Something like seqcleaner for fastq files? | hammerf | Bioinformatics | 1 | 03-16-2011 12:22 AM |
![]() |
|
Thread Tools |
![]() |
#1 |
Member
Location: san francisco Join Date: Jul 2010
Posts: 16
|
![]()
Hello, I am on an Ubuntu 12 system.
I am trying to write a bash loop to run Code:
cat /data/rad1/ang_TP30124.fastq /data/rad2/ang_TP30124.fastq > /data/rad3/ang_TP30124.fastq I have 184 files in two directories with identical file names (/data/rad1 and /data/rad2). I want to append each of the like named fastq files into a single like named file into a third directory /data/rad3. I am just learning and have come up with: Code:
topdir=/data/rad3 dir1=/data/rad1 dir2=/data/rad1 for f in $topdir/$dir1/*.fastq do outf=$topdir/`basename $f .fastq` cp $f $outf cat $topdir/$dir2/`basename $f` >> $outf done |
![]() |
![]() |
![]() |
#2 |
Senior Member
Location: St. Louis, MO, USA Join Date: Apr 2011
Posts: 124
|
![]()
Here are a couple of things I noticed.
1. dir2 should be set to /data/rad2 2. instead of $topdir/$dir1, I think it should just be $dir1 (likewise for $dir2) 3. basename includes the fastq extension, so no need to append .fastq This would be my attempt at it: Code:
topdir=/data/rad3 dir1=/data/rad1 dir2=/data/rad2 for f in $dir1/*.fastq do outf=$topdir/`basename $f` echo $outf cp $f $outf cat $dir2/`basename $f` >> $outf done Also, it might be more straightforward to do "cat a b > c" rather than "cp a c; cat b >> c;" So maybe the body could be replaced with Code:
outf=$topdir/`basename $f` cat $f $dir2/`basename $f` > $outf Justin |
![]() |
![]() |
![]() |
#3 |
Member
Location: san francisco Join Date: Jul 2010
Posts: 16
|
![]()
Thank you Justin, that worked perfectly
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Location: 66206 Join Date: Sep 2009
Posts: 23
|
![]()
here is a one-liner that uses xargs
Code:
basename -a data/rad1/*.dat | xargs -t -I {} bash -c 'cat data/rad1/"{}" data/rad2/"{}" > data/rad3/"{}" ' \;
|
![]() |
![]() |
![]() |
#5 |
Member
Location: san francisco Join Date: Jul 2010
Posts: 16
|
![]()
Thanks malcook. I will play with this, especially the xargs -P option as I have 32 cores to play with.
|
![]() |
![]() |
![]() |
#6 |
Member
Location: san francisco Join Date: Jul 2010
Posts: 16
|
![]()
Hi malcook, I tried to run this xargs one-liner, but I keep getting a basename error - "basename: invalid option -- 'a'"
I have the latest Ubuntu coreutils (8.13-3ubuntu3.1). I looked at the basename man page and there are no listed options, only help and version. |
![]() |
![]() |
![]() |
Thread Tools | |
|
|