I have one big file with lots of fasta sequences. I would like to separate the sequences by their name in files. Can anyone please help me to do so. Thanks for your time.
Hi Manshi, In this script I assume you have only two different type of fasta files, one have PP and second RR names in fasta sequence names.
#/usr/bin/perl use strict;
open(INFILE, 'input.fasta') || (warn "Can't open \n"); open OUTFILE1, ">" , 'abc1.fasta' or die "open abc1.fasta: $!"; open OUTFILE2, ">" , 'abc2.fasta' or die "open abc2.fasta: $!";
$/ = "\>"; # to break the line with > sign ..
while () { chomp $_; if ($_=~/_RR_/) { print OUTFILE1 ">$_\n"; } ## You can change the string _RR_ to anyting elsif ($_=~/_PP_/) { print OUTFILE2 ">$_\n"; }
Hi Manshi, In this script I assume you have only two different type of fasta files, one have PP and second RR names in fasta sequence names.
#Warning the script is not tested