您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)如何使用perl腳本批量生成反向互補(bǔ)序列,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
有時(shí)候我們需要得到序列的反向互補(bǔ)序列,可以用下面的腳本來(lái)批量處理序列。
用法:
perl fasta_Reverse_complementary.pl -fa input.fa -out out.fa
input.fa是輸入文件,out.fa是反向互補(bǔ)后的序列
輸入文件格式入下所示:
>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; }
關(guān)于“如何使用perl腳本批量生成反向互補(bǔ)序列”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。