Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script for breaking large .fa files into smaller files of [N] sequences

    I'm working on my first WGS assembly submission to NCBI. It's proving to be harder than the assembly itself . NCBI requires assemblies containing more than 20k contigs to be split into chunks of 10k. One of the assemblies I'm submitting has over 800k contigs.

    Anyone out there have a script that could handle this? Thanks in advance.

  • #2
    So you essentially have a fasta file with >800k unique sequences?

    You can just use the cat or split function in linux

    Comment


    • #3
      Stack Overflow | The World’s Largest Online Community for Developers




      There are multiple solutions in the links. You may need to root around to find one that does what you want.
      Last edited by GenoMax; 02-21-2014, 03:16 PM.

      Comment


      • #4
        Hi!,
        You can use script at http://stackoverflow.com/questions/1...nto-many-files

        I modified the script little bit and pasted below. If you want bigger chunks, just change "my $record_per_file = 4" value to any chunk size you like.

        Code:
        #!/usr/bin/perl
        use warnings;
        use 5.12.4;
        use File::Basename;
        #Split FASTA files into chunks determined by user.
        #by RNAeye
        
        my $file = "input.fa"; 		#enter name of your FASTA file here
        my $record_per_file = 4;	#Enter how many record you want per file / chunk size
        my $file_number = 1;		#this is going to be a part of your new file names.
        my $counter = 0;			#counts number of records
        
        open (FASTA,  "<", "$file" )   or die "Cannot open file $file $!";
        
        while (<FASTA>) {
        	if (/^>/) { 
        		if ($counter++ % $record_per_file == 0) {
        			my $basename = basename($file);
        			my $new_file_name = $basename. $file_number++ . ".fa"; 
        			close(NEW_FASTA);
        			open(NEW_FASTA, ">", $new_file_name) or die "Cannot open file $new_file_name $!";
        		}
        	}
        	print NEW_FASTA $_;	
        }

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Recent Advances in Sequencing Analysis Tools
          by seqadmin


          The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
          Yesterday, 07:48 AM
        • seqadmin
          Essential Discoveries and Tools in Epitranscriptomics
          by seqadmin




          The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
          04-22-2024, 07:01 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Today, 06:57 AM
        0 responses
        9 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, Yesterday, 07:17 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-02-2024, 08:06 AM
        0 responses
        19 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-30-2024, 12:17 PM
        0 responses
        22 views
        0 likes
        Last Post seqadmin  
        Working...
        X