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
          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 on Modified Bases...
          Yesterday, 07:01 AM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

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