这篇文章将为大家详细讲解有关如何使用perl脚本批量生成反向互补序列,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
有时候我们需要得到序列的反向互补序列,可以用下面的脚本来批量处理序列。
用法:
perl fasta_Reverse_complementary.pl -fa input.fa -out out.fa
input.fa是输入文件,out.fa是反向互补后的序列
输入文件格式入下所示:
>bta-26a-2 GGCUGUGGCUGGAUUCAAGUAAUCCAGGAUAGGCUGUUUCCAUCUGUGAGGCCUAUUCUU GAUUACUUGUUUCUGGAGGCAGCU >bta-18b CUUGUGUUAAGGUGCAUCUAGUGCAGUUAGUGAAGCAGCUCAGAAUCUACUGCCCUAAAU GCUCCUUCUGGCACA >bta-29a AUGACUGAUUUCUUUUGGUGUUCAGAGUCAAUAUAAUUUUCUAGCACCAUCUGAAAUCGG UUAU >bta-7f-2 UGUGGGAUGAGGUAGUAGAUUGUAUAGUUUUAGGGUCAUACCCCAUCUUGGAGAUAACUA UACAGUCUACUGUCUUUCCCACG
代码如下:
#!/usr/bin/perl -w use strict; use Getopt::Long; use Config::General; use Bio::SeqIO; use Bio::Seq; my $version = "1.3"; ## prepare parameters ####################################################################### ## ------------------------------------------------------------------------------------------- ## GetOptions my %opts; GetOptions(\%opts, "fa=s", "out=s","h"); if(!defined($opts{out}) || !defined($opts{fa}) ||defined($opts{h})) { print <<"Usage End."; Usage Forced parameter: -out outfile <outfile> must be given -fa fasta file <infile> must be given Other parameter: -h Help document Usage End. exit; } my $in = Bio::SeqIO->new(-file => "$opts{fa}" , -format => 'Fasta'); open(OUT,">$opts{out}") ||die "open file $opts{out} faild.\n"; while ( my $seq = $in->next_seq() ) { my($id,$sequence)=($seq->id,$seq->seq); $sequence = &reverse_complement_IUPAC($sequence); print OUT ">$id\n$sequence\n"; } sub reverse_complement_IUPAC { my $dna = shift; # reverse the DNA sequence my $revcomp = reverse($dna); # complement the reversed DNA sequence $revcomp =~ tr/ABCDGHMNRSTUVWXYabcdghmnrstuvwxy/TVGHCDKNYSAABWXRtvghcdknysaabwxr/; return $revcomp; } sub reverse_complement { my $dna = shift; # reverse the DNA sequence my $revcomp = reverse($dna); # complement the reversed DNA sequence $revcomp =~ tr/ACGTacgt/TGCAtgca/; return $revcomp; }
关于“如何使用perl脚本批量生成反向互补序列”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。