需求
客户反映,完整的基因组太大打不开,要我将之按各条染色体和scaffold拆分。如何快速实现?
方法一
借助工具:
$ pip install pyfaidx
$ faidx -x sequences.fa
方法二
自己写脚本:split.pl
#!/usr/bin/perl
$f = $ARGV[0]; #get the file name
open (INFILE, "<$f")
or die "Can't open: $f $!";
while (<INFILE>) {
$line = $_;
chomp $line;
if ($line =~ />/) { #if has fasta >
close OUTFILE;
$new_file = substr($line,1);
$new_file .= ".fa";
open (OUTFILE, ">$new_file")
or die "Can't open: $new_file $!";
}
print OUTFILE "$line
";
}
close OUTFILE;
运行:perl split.pl sequences.fa
放到一个目录中,gzip -r dir
一并发给客户。
https://www.biostars.org/p/173723/
http://seqanswers.com/forums/archive/index.php/t-32162.html