酶切位点分析(the analysis of enzyme sites)

转自 http://www.yelinsky.com/blog/archives/278.html
稍有修改

默认位点为“CCGG”。其他位点分析可修改脚本中的 my $site = ‘CCGG';和 my $n = 2;

#!/usr/bin/perl -w

use strict;
use Getopt::Long;
use Bio::SeqIO;

my %opts;

GetOptions(\%opts, "i=s", "o=s");

if (!(defined $opts{i} and defined $opts{o})){
        print "\n";
        &usage;
}

my $input_file = $opts{'i'};
my $output_file = $opts{'o'};
my $site = 'CCGG';
my $n = 2;

my $db = Bio::SeqIO->new(-format => 'fasta', -file => $input_file);

unless ( open(RESULT, ">$output_file") ) {
        print "Cannot open \"$output_file\" to write to!!\n\n";
exit;
}

while ( my $seq = $db->next_seq) {
        my $str = $seq->seq;
        if ( $str =~ /$site/ ) {
                #print RESULT index ($str, $site, 0)+$n, "\n";
                print RESULT $seq->id, " -> ", index ($str, $site, 0)+$n,"\n";
        }
}

close(RESULT);

sub usage {
        print <<"USAGE";
Usage:
        $0 -i <input_file> -o <output_file>
options:
        -i input fasta sequence file
        -o output file name
USAGE
        print "\n";
        exit(1);
}
posted @ 2015-12-07 12:51  liuhui_pine  阅读(1222)  评论(0)    收藏  举报