Bio::SeqIO
embl
Toolbar
Summary
Bio::SeqIO::embl - EMBL sequence input/output stream
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
It is probably best not to use this object directly, but
rather go through the AnnSeqIO handler system. Go:
$stream = Bio::SeqIO->new(-file => $filename, -format => 'EMBL');
while ( (my $seq = $stream->next_seq()) ) {
# do something with $seq
}
Description
This object can transform Bio::Seq objects to and from EMBL flat
file databases.
There is alot of flexibility here about how to dump things which I need
to document fully.
There should be a common object that this and genbank share (probably
with swissprot). Too much of the magic is identical.
_show_dna()
(output only) shows the dna or not
_post_sort()
(output only) provides a sorting func which is applied to the FTHelpers
before printing
_id_generation_func()
This is function which is called as
print "ID ", $func($annseq), "\n";
To generate the ID line. If it is not there, it generates a sensible ID
line using a number of tools.
If you want to output annotations in embl format they need to be
stored in a Bio::Annotation::Collection object which is accessible
through the Bio::SeqI interface method
annotation().
The following are the names of the keys which are polled from a
Bio::Annotation::Collection object.
reference - Should contain Bio::Annotation::Reference objects
comment - Should contain Bio::Annotation::Comment objects
dblink - Should contain Bio::Annotation::DBLink objects
Methods
Methods description
Title : _ac_generation_func Usage : $obj->_ac_generation_func($newval) Function: Returns : value of _ac_generation_func Args : newvalue (optional) |
Title : _filehandle Usage : $obj->_filehandle($newval) Function: Example : Returns : value of _filehandle Args : newvalue (optional) |
Title : _id_generation_func Usage : $obj->_id_generation_func($newval) Function: Returns : value of _id_generation_func Args : newvalue (optional) |
Title : _kw_generation_func Usage : $obj->_kw_generation_func($newval) Function: Returns : value of _kw_generation_func Args : newvalue (optional) |
Title : _post_sort Usage : $obj->_post_sort($newval) Function: Returns : value of _post_sort Args : newvalue (optional) |
Title : _print_EMBL_FTHelper Usage : Function: Internal function Returns : Args : |
Title : _read_EMBL_DBLink Usage : Function: Reads the EMBL database cross reference ("DR") lines Example : Returns : A list of Bio::Annotation::DBLink objects Args : |
Title : _read_EMBL_References Usage : Function: Reads references from EMBL format. Internal function really Example : Returns : Args : |
Title : _read_EMBL_Species Usage : Function: Reads the EMBL Organism species and classification lines. Example : Returns : A Bio::Species object Args : a reference to the current line buffer |
Title : _read_FTHelper_EMBL Usage : _read_FTHelper_EMBL($buffer) Function: reads the next FT key line Example : Returns : Bio::SeqIO::FTHelper object Args : filehandle and reference to a scalar |
Title : _show_dna Usage : $obj->_show_dna($newval) Function: Returns : value of _show_dna Args : newvalue (optional) |
Title : _sv_generation_func Usage : $obj->_sv_generation_func($newval) Function: Returns : value of _sv_generation_func Args : newvalue (optional) |
Title : _write_line_EMBL Usage : Function: internal function Example : Returns : Args : |
Title : _write_line_EMBL_regex Usage : Function: internal function for writing lines of specified length, with different first and the next line left hand headers and split at specific points in the text Example : Returns : nothing Args : file handle, first header, second header, text-line, regex for line breaks, total line length |
Title : next_seq Usage : $seq = $stream->next_seq() Function: returns the next sequence in the stream Returns : Bio::Seq object Args : |
Title : write_seq Usage : $stream->write_seq($seq) Function: writes the $seq object (must be seq) to the stream Returns : 1 for success and 0 for error Args : array of 1 to n Bio::SeqI objects |
Methods code
sub _ac_generation_func
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_ac_generation_func'} = $value;
}
return $obj->{'_ac_generation_func'}; } |
sub _filehandle
{ my ($obj,$value) = @_;
if( defined $value) {
$obj->{'_filehandle'} = $value;
}
return $obj->{'_filehandle'}; } |
sub _id_generation_func
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_id_generation_func'} = $value;
}
return $obj->{'_id_generation_func'}; } |
sub _initialize
{ my($self,@args) = @_;
$self->SUPER::_initialize(@args);
$self->{'_func_ftunit_hash'} = {};
$self->_show_dna(1); if( ! defined $self->sequence_factory ) {
$self->sequence_factory(new Bio::Seq::SeqFactory
(-verbose => $self->verbose(),
-type => 'Bio::Seq::RichSeq'));
} } |
sub _kw_generation_func
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_kw_generation_func'} = $value;
}
return $obj->{'_kw_generation_func'};
}
1; } |
sub _post_sort
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_post_sort'} = $value;
}
return $obj->{'_post_sort'}; } |
sub _print_EMBL_FTHelper
{ my ($self,$fth,$always_quote) = @_;
$always_quote ||= 0;
if( ! ref $fth || ! $fth->isa('Bio::SeqIO::FTHelper') ) {
$fth->warn("$fth is not a FTHelper class. Attempting to print, but there could be tears!");
}
if( $fth->key eq 'CONTIG' ) {
$self->_print("XX\n");
$self->_write_line_EMBL_regex("CO ",
"CO ",$fth->loc,
'\,|$',80); return;
}
$self->_write_line_EMBL_regex(sprintf("FT %-15s ",$fth->key),
"FT ",$fth->loc,
'\,|$',80); foreach my $tag ( keys %{$fth->field} ) {
if( ! defined $fth->field->{$tag} ) { next; }
foreach my $value ( @{$fth->field->{$tag}} ) {
$value =~ s/\"/\"\"/g;
if ($value eq "_no_value") {
$self->_write_line_EMBL_regex("FT ",
"FT ",
"/$tag",'.|$',80); }
elsif( $always_quote == 1 || $value !~ /^\d+$/ ) {
my $pat = $value =~ /\s/ ? '\s|$' : '.|$';
$self->_write_line_EMBL_regex("FT ",
"FT ",
"/$tag=\"$value\"",$pat,80);
}
else {
$self->_write_line_EMBL_regex("FT ",
"FT ",
"/$tag=$value",'.|$',80); }
}
}
}
} |
sub _read_EMBL_DBLink
{ my( $self,$buffer ) = @_;
my( @db_link );
$_ = $$buffer;
while (defined( $_ ||= $self->_readline )) {
if (my($databse, $prim_id, $sec_id)
= /^DR ([^\s;]+);\s*([^\s;]+);\s*([^\s;]+)?\.$/) {
my $link = Bio::Annotation::DBLink->new();
$link->database ( $databse );
$link->primary_id ( $prim_id );
$link->optional_id( $sec_id ) if $sec_id;
push(@db_link, $link);
}
else {
last;
}
$_ = undef; }
$$buffer = $_;
return @db_link; } |
sub _read_EMBL_References
{ my ($self,$buffer) = @_;
my (@refs);
if( $$buffer !~ /^RN/ ) {
warn("Not parsing line '$$buffer' which maybe important");
}
my $b1;
my $b2;
my $title;
my $loc;
my $au;
my $med;
my $pm;
my $com;
while( defined ($_ = $self->_readline) ) {
/^R/ || last;
/^RP (\d+)-(\d+)/ && do {$b1=$1;$b2=$2;};
/^RX MEDLINE;\s+(\d+)/ && do {$med=$1};
/^RX PUBMED;\s+(\d+)/ && do {$pm=$1};
/^RA (.*)/ && do {
$au = $self->_concatenate_lines($au,$1); next;
};
/^RT (.*)/ && do {
$title = $self->_concatenate_lines($title,$1); next;
};
/^RL (.*)/ && do {
$loc = $self->_concatenate_lines($loc,$1); next;
};
/^RC (.*)/ && do {
$com = $self->_concatenate_lines($com,$1); next;
};
}
my $ref = new Bio::Annotation::Reference;
$au =~ s/;\s*$//g;
$title =~ s/;\s*$//g;
$ref->start($b1);
$ref->end($b2);
$ref->authors($au);
$ref->title($title);
$ref->location($loc);
$ref->medline($med);
$ref->comment($com);
$ref->pubmed($pm);
push(@refs,$ref);
$$buffer = $_;
return @refs; } |
sub _read_EMBL_Species
{ my( $self, $buffer ) = @_;
my $org;
$_ = $$buffer;
my( $sub_species, $species, $genus, $common, @class );
while (defined( $_ ||= $self->_readline )) {
if (/^OS\s+(\S+)(?:\s+([^\(]\S*))?(?:\s+([^\(]\S*))?(?:\s+\((.*)\))?/) {
$genus = $1;
$species = $2 || 'sp.';
$sub_species = $3 if $3;
$common = $4 if $4;
}
elsif (s/^OC\s+//) {
chomp;
push(@class, map { s/^\s+//; s/\s+$//; $_; } split /[;\.]+/);
}
elsif (/^OG\s+(.*)/) {
$org = $1;
}
else {
last;
}
$_ = undef; }
$$buffer = $_;
return if $genus =~ /^(Unknown|None)$/i;
if ($class[$#class] eq $genus) {
push( @class, $species );
} else {
push( @class, $genus, $species );
}
@class = reverse @class;
my $make = Bio::Species->new();
$make->classification(\@ class, "FORCE" ); $make->common_name( $common ) if $common;
$make->sub_species( $sub_species ) if $sub_species;
$make->organelle ( $org ) if $org;
return $make; } |
sub _read_FTHelper_EMBL
{ my ($self,$buffer) = @_;
my ($key, $loc, @qual, );
if ($$buffer =~ /^FT\s{3}(\S+)\s+(\S+)/) {
$key = $1;
$loc = $2;
while ( defined($_ = $self->_readline) ) {
if (/^FT(\s+)(.+?)\s*$/) {
if (length($1) > 4) {
if (@qual) {
push(@qual, $2);
}
elsif (substr($2, 0, 1) eq '/') {
@qual = ($2);
}
else {
$loc .= $2;
}
} else {
last;
}
} else {
last;
}
}
} elsif( $$buffer =~ /^CO\s+(\S+)/) {
$key = 'CONTIG';
$loc = $1;
while ( defined($_ = $self->_readline) ) {
if (/^CO\s+(\S+)\s*$/) {
$loc .= $1;
} else {
last;
}
}
} else {
return;
}
$$buffer = $_;
my $out = new Bio::SeqIO::FTHelper();
$out->verbose($self->verbose());
$out->key($key);
$out->loc($loc);
QUAL: for (my $i = 0; $i < @qual; $i++) {
$_ = $qual[$i];
my( $qualifier, $value ) = m{^/([^=]+)(?:=(.+))?}
or $self->throw("Can't see new qualifier in: $_\nfrom:\n"
. join('', map "$_\n", @qual));
if (defined $value) {
if (substr($value, 0, 1) eq '"') {
while ($value !~ /"$/ or $value =~ tr/"/"/ % 2) { $i++;
my $next = $qual[$i];
unless (defined($next)) {
warn("Unbalanced quote in:\n", map("$_\n", @qual),
"No further qualifiers will be added for this feature");
last QUAL;
}
$value .= (grep /\s/, ($value, $next)) ? " $next" : $next;
}
$value =~ s/^"|"$//g;
$value =~ s/""/"/g; }
} else {
$value = '_no_value';
}
$out->field->{$qualifier} ||= [];
push(@{$out->field->{$qualifier}},$value);
}
return $out; } |
sub _show_dna
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_show_dna'} = $value;
}
return $obj->{'_show_dna'}; } |
sub _sv_generation_func
{ my $obj = shift;
if( @_ ) {
my $value = shift;
$obj->{'_sv_generation_func'} = $value;
}
return $obj->{'_sv_generation_func'}; } |
sub _write_line_EMBL
{ my ($self,$pre1,$pre2,$line,$length) = @_;
$length || die "Miscalled write_line_EMBL without length. Programming error!";
my $subl = $length - length $pre2;
my $linel = length $line;
my $i;
my $sub = substr($line,0,$length - length $pre1);
$self->_print( "$pre1$sub\n");
for($i= ($length - length $pre1);$i < $linel;) {
$sub = substr($line,$i,($subl));
$self->_print( "$pre2$sub\n");
$i += $subl;
} } |
sub _write_line_EMBL_regex
{ my ($self,$pre1,$pre2,$line,$regex,$length) = @_;
$length || die "Programming error - called write_line_EMBL_regex without length.";
my $subl = $length - (length $pre1) -1 ;
my( @lines );
while(defined $line &&
$line =~ m/(.{1,$subl})($regex)/g) { push(@lines, $1.$2); }
foreach (@lines) { s/\s+$//; }
my $s = shift(@lines) || '';
$self->_print( "$pre1$s\n");
foreach my $s ( @lines ) {
$s = '' if( !defined $s );
$self->_print( "$pre2$s\n");
} } |
sub next_seq
{ my ($self,@args) = @_;
my ($pseq,$c,$line,$name,$desc,$acc,$seqc,$mol,$div,
$date, $comment, @date_arr);
my ($annotation, %params, @features) = ( new Bio::Annotation::Collection);
$line = $self->_readline;
if( !defined $line ) {
return undef; }
if( $line =~ /^\s+$/ ) {
while( defined ($line = $self->_readline) ) {
$line =~/^\S/ && last;
}
}
if( !defined $line ) {
return undef; }
$line =~ /^ID\s+\S+/ || $self->throw("EMBL stream with no ID. Not embl in my book");
$line =~ /^ID\s+(\S+)\s+\S+\;\s+([^;]+)\;\s+(\S+)\;/;
$name = $1;
$mol = $2;
$div = $3;
if(! $name) {
$name = "unknown id";
}
my $alphabet;
if($mol) {
if ( $mol =~ /circular/ ) {
$params{'-is_circular'} = 1;
$mol =~ s|circular ||;
}
if (defined $mol ) {
if ($mol =~ /DNA/) {
$alphabet='dna';
}
elsif ($mol =~ /RNA/) {
$alphabet='rna';
}
elsif ($mol =~ /AA/) {
$alphabet='protein';
}
}
}
my $buffer = $line;
local $_;
BEFORE_FEATURE_TABLE :
until( !defined $buffer ) {
$_ = $buffer;
last if /^F[HT]/;
if (/^DE\s+(\S.*\S)/) {
$desc .= $desc ? " $1" : $1;
}
if( /^AC\s+(.*)?/ ) {
my @accs = split(/[; ]+/, $1); $params{'-accession_number'} = shift @accs
unless defined $params{'-accession_number'};
push @{$params{'-secondary_accessions'}}, @accs;
}
if( /^SV\s+\S+\.(\d+);?/ ) {
my $sv = $1;
$params{'-seq_version'} = $sv;
$params{'-version'} = $sv;
}
if( /^DT\s+(.+)$/ ) {
my $date = $1;
push @{$params{'-dates'}}, $date;
}
if( /^KW\s+(.*)\S*$/ ) {
my @kw = split(/\s*\;\s*/,$1);
push @{$params{'-keywords'}}, @kw;
}
elsif (/^O[SC]/) {
my $species = $self->_read_EMBL_Species(\$buffer);
$params{'-species'}= $species;
}
elsif (/^R/) {
my @refs = $self->_read_EMBL_References(\$buffer);
foreach my $ref ( @refs ) {
$annotation->add_Annotation('reference',$ref);
}
}
elsif (/^DR/) {
my @links = $self->_read_EMBL_DBLink(\$buffer);
foreach my $dblink ( @links ) {
$annotation->add_Annotation('dblink',$dblink);
}
}
elsif (/^CC\s+(.*)/) {
$comment .= $1;
$comment .= " ";
while (defined ($_ = $self->_readline) ) {
if (/^CC\s+(.*)/) {
$comment .= $1;
$comment .= " ";
}
else {
last;
}
}
my $commobj = Bio::Annotation::Comment->new();
$commobj->text($comment);
$annotation->add_Annotation('comment',$commobj);
$comment = "";
}
$buffer = $self->_readline;
}
while( defined ($_ = $self->_readline) ) {
/^FT \w/ && last;
/^SQ / && last;
/^CO / && last;
}
$buffer = $_;
if (defined($buffer) && $buffer =~ /^FT /) {
until( !defined ($buffer) ) {
my $ftunit = $self->_read_FTHelper_EMBL(\$buffer);
push(@features,
$ftunit->_generic_seqfeature($self->location_factory(), $name));
if( $buffer !~ /^FT/ ) {
last;
}
}
}
while( defined ($buffer) && $buffer =~ /^XX/ ) {
$buffer = $self->_readline();
}
if( $buffer =~ /^CO/ ) {
until( !defined ($buffer) ) {
my $ftunit = $self->_read_FTHelper_EMBL(\$buffer);
push(@features,
$ftunit->_generic_seqfeature($self->location_factory(),
$name));
if( $buffer !~ /^CO/ ) {
last;
}
}
}
if( $buffer !~ /^SQ/ ) {
while( defined ($_ = $self->_readline) ) {
/^SQ/ && last;
}
}
$seqc = "";
while( defined ($_ = $self->_readline) ) {
/^\/\// && last;
$_ = uc($_);
s/[^A-Za-z]//g;
$seqc .= $_;
}
my $seq = $self->sequence_factory->create
(-verbose => $self->verbose(),
-division => $div,
-seq => $seqc,
-desc => $desc,
-display_id => $name,
-annotation => $annotation,
-molecule => $mol,
-alphabet => $alphabet,
-features =>\@ features,
%params);
return $seq; } |
sub write_seq
{ my ($self,@seqs) = @_;
foreach my $seq ( @seqs ) {
$self->throw("Attempting to write with no seq!") unless defined $seq;
unless ( ref $seq && $seq->isa('Bio::SeqI' ) ) {
$self->warn("$seq is not a SeqI compliant sequence object!")
if $self->verbose >= 0;
unless ( ref $seq && $seq->isa('Bio::PrimarySeqI' ) ) {
$self->throw("$seq is not a PrimarySeqI compliant sequence object!");
}
}
my $str = $seq->seq || '';
my $mol;
my $div;
my $len = $seq->length();
if ($seq->can('division') && defined $seq->division) {
$div = $seq->division();
}
$div ||= 'UNK';
if ($seq->can('molecule')) {
$mol = $seq->molecule();
$mol = 'RNA' if defined $mol && $mol =~ /RNA/; }
elsif ($seq->can('primary_seq') && defined $seq->primary_seq->alphabet) {
my $alphabet =$seq->primary_seq->alphabet;
if ($alphabet eq 'dna') {
$mol ='DNA';
}
elsif ($alphabet eq 'rna') {
$mol='RNA';
}
elsif ($alphabet eq 'protein') {
$mol='AA';
}
}
$mol ||= 'XXX';
$mol = "circular $mol" if $seq->is_circular;
my $temp_line;
if( $self->_id_generation_func ) {
$temp_line = &{$self->_id_generation_func}($seq);
} else {
$temp_line = sprintf("%-11sstandard; $mol; $div; %d BP.", $seq->id(), $len);
}
$self->_print( "ID $temp_line\n","XX\n");
my( $acc );
{
if( my $func = $self->_ac_generation_func ) {
$acc = &{$func}($seq);
} elsif( $seq->isa('Bio::Seq::RichSeqI') &&
defined($seq->accession_number) ) {
$acc = $seq->accession_number;
$acc = join(";", $acc, $seq->get_secondary_accessions);
} elsif ( $seq->can('accession_number') ) {
$acc = $seq->accession_number;
}
if (defined $acc) {
$self->_print("AC $acc;\n",
"XX\n");
}
}
{
my( $sv );
if (my $func = $self->_sv_generation_func) {
$sv = &{$func}($seq);
} elsif($seq->isa('Bio::Seq::RichSeqI') &&
defined($seq->seq_version)) {
$sv = "$acc.". $seq->seq_version();
}
if (defined $sv) {
$self->_print( "SV $sv\n",
"XX\n");
}
}
my $switch=0;
if( $seq->can('get_dates') ) {
foreach my $dt ( $seq->get_dates() ) {
$self->_write_line_EMBL_regex("DT ","DT ",$dt,'\s+|$',80); $switch=1;
}
if ($switch == 1) {
$self->_print("XX\n");
}
}
$self->_write_line_EMBL_regex("DE ","DE ",$seq->desc(),'\s+|$',80); $self->_print( "XX\n");
{
my( $kw );
if( my $func = $self->_kw_generation_func ) {
$kw = &{$func}($seq);
} elsif( $seq->can('keywords') ) {
$kw = $seq->keywords;
if( ref($kw) =~ /ARRAY/i ) {
$kw = join("; ", @$kw);
}
$kw .= '.' if( defined $kw && $kw !~ /\.$/ );
}
if (defined $kw) {
$self->_write_line_EMBL_regex("KW ", "KW ",
$kw, '\s+|$', 80); $self->_print( "XX\n");
}
}
if ($seq->can('species') && (my $spec = $seq->species)) {
my($species, @class) = $spec->classification();
my $genus = $class[0];
my $OS = "$genus $species";
if (my $ssp = $spec->sub_species) {
$OS .= " $ssp";
}
if (my $common = $spec->common_name) {
$OS .= " ($common)";
}
$self->_print("OS $OS\n");
my $OC = join('; ', reverse(@class)) .'.';
$self->_write_line_EMBL_regex("OC ","OC ",$OC,'; |$',80); if ($spec->organelle) {
$self->_write_line_EMBL_regex("OG ","OG ",$spec->organelle,'; |$',80); }
$self->_print("XX\n");
}
my $t = 1;
if ( $seq->can('annotation') && defined $seq->annotation ) {
foreach my $ref ( $seq->annotation->get_Annotations('reference') ) {
$self->_print( "RN [$t]\n");
my $start = $ref->start;
my $end = $ref->end;
if ($start and $end) {
$self->_print( "RP $start-$end\n");
} elsif ($start or $end) {
$self->throw("Both start and end are needed for a valid RP line. Got: start='$start' end='$end'");
}
if (my $med = $ref->medline) {
$self->_print( "RX MEDLINE; $med.\n");
}
if (my $pm = $ref->pubmed) {
$self->_print( "RX PUBMED; $pm.\n");
}
$self->_write_line_EMBL_regex("RA ", "RA ",
$ref->authors . ";",
'\s+|$', 80);
my $ref_title = $ref->title || '';
$ref_title =~ s/[\s;]*$/;/;
$self->_write_line_EMBL_regex("RT ", "RT ", $ref_title, '\s+|$', 80); $self->_write_line_EMBL_regex("RL ", "RL ", $ref->location, '\s+|$', 80); if ($ref->comment) {
$self->_write_line_EMBL_regex("RC ", "RC ", $ref->comment, '\s+|$', 80); }
$self->_print("XX\n");
$t++;
}
if (my @db_xref = $seq->annotation->get_Annotations('dblink') ) {
foreach my $dr (@db_xref) {
my $db_name = $dr->database;
my $prim = $dr->primary_id;
my $opt = $dr->optional_id || '';
my $line = "$db_name; $prim; $opt.";
$self->_write_line_EMBL_regex("DR ", "DR ", $line, '\s+|$', 80); }
$self->_print("XX\n");
}
foreach my $comment ( $seq->annotation->get_Annotations('comment') ) {
$self->_write_line_EMBL_regex("CC ", "CC ", $comment->text, '\s+|$', 80); $self->_print("XX\n");
}
}
$self->_print("FH Key Location/Qualifiers\n");
$self->_print("FH\n");
my @feats = $seq->can('top_SeqFeatures') ? $seq->top_SeqFeatures : ();
if ($feats[0]) {
if( defined $self->_post_sort ) {
my $post_sort_func = $self->_post_sort();
my @fth;
foreach my $sf ( @feats ) {
push(@fth,Bio::SeqIO::FTHelper::from_SeqFeature($sf,$seq));
}
@fth = sort { &$post_sort_func($a,$b) } @fth;
foreach my $fth ( @fth ) {
$self->_print_EMBL_FTHelper($fth);
}
} else {
foreach my $sf ( @feats ) {
my @fth = Bio::SeqIO::FTHelper::from_SeqFeature($sf,$seq);
foreach my $fth ( @fth ) {
if( $fth->key eq 'CONTIG') {
$self->_show_dna(0);
}
$self->_print_EMBL_FTHelper($fth);
}
}
}
}
if( $self->_show_dna() == 0 ) {
$self->_print( "//\n");
return;
}
$self->_print( "XX\n");
$str =~ tr/A-Z/a-z/;
my $alen = $str =~ tr/a/a/;
my $clen = $str =~ tr/c/c/;
my $glen = $str =~ tr/g/g/;
my $tlen = $str =~ tr/t/t/;
my $olen = $len - ($alen + $tlen + $clen + $glen);
if( $olen < 0 ) {
$self->warn("Weird. More atgc than bases. Problem!");
}
$self->_print("SQ Sequence $len BP; $alen A; $clen C; $glen G; $tlen T; $olen other;\n");
my $nuc = 60; my $whole_pat = 'a10' x 6; my $out_pat = 'A11' x 6; my $length = length($str);
my $whole = int($length / $nuc) * $nuc;
my( $i );
for ($i = 0; $i < $whole; $i += $nuc) {
my $blocks = pack $out_pat,
unpack $whole_pat,
substr($str, $i, $nuc);
$self->_print(sprintf(" $blocks%9d\n", $i + $nuc));
}
if (my $last = substr($str, $i)) {
my $last_len = length($last);
my $last_pat = 'a10' x int($last_len / 10) .'a'. $last_len % 10; my $blocks = pack $out_pat,
unpack($last_pat, $last);
$self->_print(sprintf(" $blocks%9d\n", $length)); }
$self->_print( "//\n");
$self->flush if $self->_flush_on_write && defined $self->_fh;
return 1;
} } |
General documentation
User feedback is an integral part of the evolution of this
and other Bioperl modules. Send your comments and suggestions preferably
to one of the Bioperl mailing lists.
Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://www.bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution.
Bug reports can be submitted via email or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _