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
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        18 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        22 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        17 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Working...
        X