Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lac302
    Member
    • Dec 2012
    • 64

    #1

    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.
  • JackieBadger
    Senior Member
    • Mar 2009
    • 385

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

    You can just use the cat or split function in linux

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      http://stackoverflow.com/questions/1...-of-first-line

      http://www.biostars.org/p/13270/

      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

      • rnaeye
        Member
        • May 2011
        • 80

        #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

        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          Yesterday, 09:55 AM
        • SEQadmin2
          New Genomics Technologies Take Aim at Long-Standing Limits
          by SEQadmin2


          Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

          We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
          ...
          09-28-2026, 10:25 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Today, 10:52 AM
        0 responses
        8 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 05:39 AM
        0 responses
        14 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-13-2026, 09:56 AM
        0 responses
        15 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-09-2026, 11:14 AM
        0 responses
        27 views
        0 reactions
        Last Post SEQadmin2  
        Working...