#!/usr/bin/perl
use Bio::SeqIO;
use Bio::Seq;
use Tie::File;
use Cwd;
$location_dir=getcwd;
$location_dir=~s/\//\\/;
@file = glob("$location_dir\\*.filter");
foreach $file(@file){
open(DATA,"<$file") or die "Can't open $file";
@list = <DATA>;
foreach $list (@list){
@list_elm=split(" ",$list);
if($list_elm[0]=~/location_start/){
$location_start=$list_elm[1];
}
if($list_elm[0]=~/location_end/){
$location_end=$list_elm[1];
}
}
close DATA;
}
$location_dir=getcwd;
$location_dir=~s/\//\\/;
@file = glob("$location_dir\\database\\*.fa");
$dirpath="$location_dir\\cutted";
mkdir ($dirpath);
foreach $file(@file){
$fa=Bio::SeqIO->new(-file=>$file,-format=>'fasta');
print " successful import $file\n";
while($seq_obj=$fa->next_seq){
$id=$seq_obj->id;
$seq=$seq_obj->seq;
$length=$seq_obj->length;
$seq_length=@seq;
$desc=$seq_obj->desc;
$seqs=$seq;
@seqs=split("",$seqs);
@now=@seqs[$location_start-1..$location_end-1];
$now=join('', @now);
$files=$file;
$files=~s/\://g;
$num=$files=~s/\\/_/g;
$files=~s/\.fa//;
@files=split("_",$files);
open WH, ">>$dirpath\\$files[$num].cutted";
print WH ">$id $desc\n";
print WH "$now\n";
close WH;
}
}
附件:Easyseq源码([6]cut)
于 2024-08-04 12:07:01 首次发布