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
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM
        • seqadmin
          Techniques and Challenges in Conservation Genomics
          by seqadmin



          The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

          Avian Conservation
          Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
          03-08-2024, 10:41 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Yesterday, 06:37 PM
        0 responses
        8 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, Yesterday, 06:07 PM
        0 responses
        8 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-22-2024, 10:03 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-21-2024, 07:32 AM
        0 responses
        66 views
        0 likes
        Last Post seqadmin  
        Working...
        X