SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing a MEGAN file by command line matias_irazoqui Bioinformatics 1 08-02-2016 02:18 PM
picard 1.139 command errors on but added to path on ubuntu 14.04 cmccabe Bioinformatics 0 11-03-2015 02:10 PM
Help with Cufflinks in command line ccard28 Bioinformatics 4 02-24-2013 10:27 PM
MEGAN from the command line oTrout Bioinformatics 4 10-30-2012 05:31 AM
SIFT on the command line lamasmi Bioinformatics 2 08-17-2010 10:32 AM

Reply
 
Thread Tools
Old 01-19-2018, 05:12 PM   #1
j.cappellazzi
Member
 
Location: Oregon

Join Date: Aug 2017
Posts: 12
Question Qiime Ubuntu Command Line File Name Code?

After running multiple_join_paired_ends.py on my 600 Illumina MiSeq files, the output leaves each sample in individual folders. The folder has a unique name, but all of the files in each subdirectory have the name "fastqjoin.join.fastq."

In order to continue with split_libraries.py, I need to have all of the .fastq files in a single folder with unique names to identify the samples.

Is there a script to rename all of the files in each folder with the name of the folder they are in? This is how my filing system works...

/home/qiime/desktop/Final_Analysis/join_paired_ends_fastq-join/600 uniquely named folders, within each folder is a single joined .fastq file, but all of the files have the same name of "fastqjoin.join.fastq"

If each of those files could be renamed to the name of the folder they are in, I could just move them to another directory easily and each would have a unique identifier. Basically, I am trying to avoid individually going in and renaming each of the 600 files.

Any help would be greatly appreciated!
j.cappellazzi is offline   Reply With Quote
Old 01-20-2018, 02:17 PM   #2
kmcarr
Senior Member
 
Location: USA, Midwest

Join Date: May 2008
Posts: 1,139
Default

In this situation you want to use multiple_split_libraries_fastq.py http://qiime.org/scripts/multiple_sp...ies_fastq.html

From the documentation this script may be invoked on
Quote:
a directory containing many directories, where each directory is named on a per-sample basis
to iteratively run split_libraries_fastq.py on each subdirectory.
kmcarr is offline   Reply With Quote
Old 01-21-2018, 01:20 PM   #3
j.cappellazzi
Member
 
Location: Oregon

Join Date: Aug 2017
Posts: 12
Default

Thanks for the quick response kmcarr. I forgot to mention another step in the pipeline in my first post. Before I run multiple_split_libraries_fastq.py, I would like to run count_seqs.py as well as use the fastx_toolkit on those joined reads. In order to do this, the files need to be in a single folder with unique names.

Is there a way (script) to rename the files with unique names (which they will hold through all of the analyses) that you are aware of. Essentially, is there an answer to my first question, not necessarily for the split libraries script but for sample organization? Thanks.
j.cappellazzi is offline   Reply With Quote
Old 01-21-2018, 03:16 PM   #4
neavemj
Member
 
Location: MA, USA

Join Date: Feb 2014
Posts: 47
Default

Hi j.cappellazzi,

I think the below should work for renaming your files if you're sure qiime won't do it for you, or complain later when all the files are renamed. Be careful though - I wouldn't want to mess up all your files! Maybe you could try this on a dummy example first, or backup your files beforehand.

Change into the base directory

Code:
cd /home/qiime/desktop/Final_Analysis/join_paired_ends_fastq-join/
Loop through each folder and rename it's containing fastq file with the folder name:

Code:
for j in */; do mv $j/fastqjoin.join.fastq $j/$(basename $j); done
Or if you want the renamed files to also end with ".fastq":

Code:
for j in */; do mv $j/fastqjoin.join.fastq $j/$(basename $j).fastq; done
Or if you want all the files in the current directory (rather than in their individual directories):

Code:
for j in */; do mv $j/fastqjoin.join.fastq $(basename $j).fastq; done
Cheers,

Matt.
neavemj is offline   Reply With Quote
Old 01-22-2018, 12:55 PM   #5
j.cappellazzi
Member
 
Location: Oregon

Join Date: Aug 2017
Posts: 12
Default

Thanks neavemj! That was perfect. All of the files are now renamed. I will keep going on these practice files to make sure all is well, but I think that's exactly what I wanted :-). I need to take a coding class.
j.cappellazzi is offline   Reply With Quote
Old 01-22-2018, 02:13 PM   #6
neavemj
Member
 
Location: MA, USA

Join Date: Feb 2014
Posts: 47
Default

Excellent!

I was thinking you could probably also do a copy (cp) rather than renaming the files:

Code:
for j in */; do cp $j/fastqjoin.join.fastq $(basename $j).fastq; done
This would leave the fastqjoin.join.fastq files in their original directory, and make a copy (with the directory name) and put them in the current directory.

Cheers,

Matt.
neavemj is offline   Reply With Quote
Reply

Tags
batch, command line, filename, qiime, ubuntu

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO