溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

bioperl怎么處理fasta和fastq序列

發布時間:2022-03-18 17:02:35 來源:億速云 閱讀:204 作者:iii 欄目:開發技術

這篇文章主要介紹“bioperl怎么處理fasta和fastq序列”的相關知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強,希望這篇“bioperl怎么處理fasta和fastq序列”文章能幫助大家解決問題。

bioperl處理fasta序列最全代碼:

序列的讀取與輸出
use Bio::SeqIO;
use Bio::Seq;
use Data::Dumper;
$in  = Bio::SeqIO->new(-file => "D:/share/scripts/Arabidopsis_thaliana.TAIR10.cds.all.fa" ,
                               -alphabet=>"dna",
                               -format => 'Fasta');
$out = Bio::SeqIO->new(-file => ">D:/share/scripts/aa.fa" ,
                               -format => 'fasta');
while ( my $seqobj = $in->next_seq() ) {
# the human read-able id of the sequence
my $id=$seqobj->id(); 
 
# string of sequence
my $seq=$seqobj->seq();
# a description of the sequence
my $desc=$seqobj->desc(); 
# one of 'dna','rna','protein'  https://www.bioinformatics.org/sms/iupac.html
my $alphabet=$seqobj->alphabet(); 
my $len=$seqobj->length();
print $id."\n";
print $seq."\n";
print $desc."\n";
print $alphabet."\n";
print $len."\n";
print $seqobj."\n";
print Dumper($seqobj);
$out->write_seq($seqobj);
last;
}
Fastq序列的處理:
$in1  = Bio::SeqIO->new(-file => "D:/share/scripts/test_1.fastq" ,
                               -format => 'fastq');
$in2  = Bio::SeqIO->new(-file => "D:/share/scripts/test_2.fastq" ,
                               -format => 'fastq');
                               
$out = Bio::SeqIO->new(-file => ">D:/share/scripts/test_1.fa" ,
                               -format => 'fasta');
while ( my $seqobj1 = $in1->next_seq() and  my $seqobj2 = $in2->next_seq()) {
# the human read-able id of the sequence
my $id=$seqobj->id(); 
# string of sequence
my $seq=$seqobj->seq(); 
# a description of the sequence
my $desc=$seqobj->desc(); 
# one of 'dna','rna','protein'  https://www.bioinformatics.org/sms/iupac.html
my $alphabet=$seqobj->alphabet(); 
my $len=$seqobj->length();
my $qual=$seqobj->qual();
print $id."\n";
print $seq."\n";
print $desc."\n";
print $alphabet."\n";
print $len."\n";
print "@{$qual}\n";
print Dumper($seqobj);
$out->write_seq($seqobj);
last;
}
序列的截取  反向互補序列:
my$seqobj = Bio::Seq->new(-seq => 'actgtggcgtcaact',-desc => 'Sample Bio::Seq object',-id =>"ID1");
# part of the sequence as a string
my$subseq=$seqobj->subseq(5,10); 
print $subseq."\n";
my $newSeqobj = Bio::Seq->new(-seq => $subseq,
       -desc => 'subseq 5-10',
       -id =>"ID2",
 );
$out->write_seq($newSeqobj);


trunc和subseq有區別,trunc返回還是原來的序列對象,只是截短了,而subseq返回的是截取的序列字符串,一般subseq使用的多一些:

$out  = Bio::SeqIO->new(-file => ">D:/share/scripts/subseq1.fa" ,
                               -format => 'Fasta');
 
my$subseqObj= $seqobj->trunc(5,10);
my$subseq=$seqobj->subseq(5,10);
print $subseqObj."\n";
print $subseq."\n";
$out->write_seq($subseqObj);
my$revcom= $seqobj->revcom;  #序列反向互補
print   $revcom."\n";
print $subseqObj."\n";
print   $seqobj."\n";
DNA序列翻譯成蛋白質序列:

#參數   1  stop *

#     2   unknown amino acid ('X').

my$translate0=$seqobj->translate(undef,undef,0);
my$translate1=$seqobj->translate(undef,undef,1);
my$translate2=$seqobj->translate(undef,undef,2);

print Dumper($translate0)."\n";
print Dumper($translate1)."\n";
print Dumper($translate2)."\n";

關于“bioperl怎么處理fasta和fastq序列”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識,可以關注億速云行業資訊頻道,小編每天都會為大家更新不同的知識點。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女