Get the App
SLTechnology News&Howtos  ›  Development  › 

How does bioperl deal with fasta and fastq sequences

Shulou Source: shulou.com Published: 2022-06-01 04:56:22 10月09日 Update

This article mainly introduces the relevant knowledge of "how bioperl deals with fasta and fastq sequences". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how bioperl deals with fasta and fastq sequences" can help you solve the problem.

Bioperl handles the most complete code of the fasta sequence:

Sequence reading and output 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 sequencemy $id=$seqobj- > id (); # string of sequencemy $seq=$seqobj- > seq (); # a description of the sequencemy $desc=$seqobj- > desc () # one of 'dna','rna','protein' https://www.bioinformatics.org/sms/iupac.htmlmy $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 sequence processing: $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 sequencemy $id=$seqobj- > id (); # string of sequencemy $seq=$seqobj- > seq () # a description of the sequencemy $desc=$seqobj- > desc (); # one of 'dna','rna','protein' https://www.bioinformatics.org/sms/iupac.htmlmy $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 } sequence: my$seqobj = Bio::Seq- > new (- seq= > 'actgtggcgtcaact',-desc = >' Sample Bio::Seq object',-id = > "ID1"); # part of the sequence as a stringmy$subseq=$seqobj- > subseq (5pm 10); print $subseq. "\ n"; my$ newSeqobj = Bio::Seq- > new (- seq= > $subseq,-desc = > 'subseq 5-10,-id = > "ID2",); $out- > write_seq ($newSeqobj)

Trunc is different from subseq. Trunc returns the original sequence object, but it is truncated, while subseq returns the intercepted sequence string. Generally, subseq uses more:

$out = Bio::SeqIO- > new (- file = > "> D:/share/scripts/subseq1.fa",-format = > 'Fasta'); my$subseqObj= $seqobj- > trunc (5d10); my$subseq=$seqobj- > subseq (5d10); print $subseqObj. "\ n"; print $subseq. "\ n"; $out- > write_seq ($subseqObj); my$revcom= $seqobj- > revcom; # sequence reverse complementary print $revcom. "\ n"; print $subseqObj. "\ n"; print $seqobj. "\ n" DNA sequence is translated into protein sequence:

# Parameter 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"; that's all for bioperl's how to deal with fasta and fastq sequences. Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Sequence processing knowledge industry different practical most complete code content parameters just characters strings practicality actual objects articles methods more cases Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology MySQL MariaDB Microsoft