您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關如何使用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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。