Bio::Assembly::IO
ace
Toolbar
Summary
Bio::Assembly::IO::ace - module to load ACE files from various assembly programs
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
# Building an input stream
use Bio::Assembly::IO;
# Load a reference ACE assembly
my $in_io = Bio::Assembly::IO->new( -file => 'results.ace',
-format => 'ace' );
# Read the entire scaffold
my $scaffold = $in_io->next_assembly;
# Or read one contig at a time to save resources
while ( my $contig = $in_io->next_contig ) {
# Do something ...
}
# Assembly writing methods
my $out_io = Bio::Assembly::IO->new( -file => ">output.ace",
-format => 'ace' );
$out_io->write_assembly( -scaffold => $scaffold,
-singlets => 1 );
# Read the '454' Newbler variant of ACE instead of the default 'consed'
# reference ACE variant
my $in_io = Bio::Assembly::IO->new( -file => 'results.ace',
-format => 'ace-454' );
# or ...
my $in_io = Bio::Assembly::IO->new( -file => 'results.ace',
-format => 'ace',
-variant => '454' );
Description
This package loads the standard ACE files generated by various assembly programs
(Phrap, CAP3, Newbler, Arachne, ...). It was written to be used as a driver
module for Bio::Assembly::IO input/output.
Assemblies are loaded into Bio::Assembly::Scaffold objects composed by
Bio::Assembly::Contig and Bio::Assembly::Singlet objects. Only the ACE file is
used, so if you need singlets, make sure that they are present in the ACE file.
A brief description of the ACE format is available at
http://www.cbcb.umd.edu/research/contig_representation.shtml#ACE
Read the full format description from
http://bozeman.mbt.washington.edu/consed/distributions/README.14.0.txtIn addition to default "_aligned_coord:$seqID" feature class from
Bio::Assembly::Contig, contig objects loaded by this module will have the
following special feature classes in their feature collection:
"_align_clipping:$seqID" (AF)
Location of subsequence in read $seqID which is aligned to the contig. The
coordinates are relative to the contig. If no feature containing this tag is
present the read is considered low quality by Consed.
"_quality_clipping:$seqID" (AF)
The location of high quality subsequence in read $seqID (relative to contig)
"_base_segments" (BS)
Location of read subsequences used to build the consensus
"_read_tags:$readID" (RT)
Sequence features stored as sub_SeqFeatures of the sequence's coordinate
feature (the corresponding "_aligned_coord:$seqID" feature, easily accessed
through get_seq_coord() method).
"_read_desc:$readID" (DS)
Sequence features stored as sub_SeqFeatures of the read's coordinate feature
"consensus tags" (CT)
Equivalent to a bioperl sequence feature and, therefore, are added to the
feature collection using their type field (see Consed's README.txt file) as
primary tag.
"whole assembly tags" (WA)
They have no start and end, as they are not associated to any particular
sequence in the assembly, and are added to the assembly's annotation
collection using "whole assembly" as tag.
The default ACE variant is called 'consed' and corresponds to the reference ACE
format.
The ACE files produced by the 454 GS Assembler (Newbler) do not conform to the
reference ACE format. In 454 ACE, the consensus sequence reported covers only
its clear range and the start of the clear range consensus is defined as position
1. Consequently, aligned reads in the contig can have negative positions. Be sure
to use the '454' variant to have positive alignment positions. No attempt is made
to construct the missing part of the consensus sequence (beyond the clear range)
based on the underlying reads in the contig. Instead the ends of the consensus
are simply padded with the gap character '-'.
Methods
Methods description
Title : next_assembly Usage : $scaffold = $stream->next_assembly() Function: returns the next assembly in the stream Returns : a Bio::Assembly::Scaffold object Args : none |
Title : next_contig Usage : $scaffold = $stream->next_contig() Function: Returns the next contig or singlet in the ACE stream. Returns : a Bio::Assembly::Contig or Bio::Assembly::Single object Args : none |
Title : scaffold_annotations Usage : $stream->scaffold_annotations($scaffold) Function: Add assembly and contig annotations to a scaffold. In the ACE format, annotations are the WA and CT tags. Returns : 1 for success Args : a Bio::Assembly::Scaffold object to attach the annotations to |
Title : write_contig Usage : $ass_io->write_contig($contig) Function: Write a contig or singlet object in ACE compatible format. Quality scores are automatically generated if the contig does not contain any Returns : 1 on success, 0 for error Args : A Bio::Assembly::Contig or Singlet object |
Title : write_header Usage : $ass_io->write_header($scaffold) or $ass_io->write_header(\@contigs); or $ass_io->write_header(); Function: Write ACE header (AS tags). You can call this function at any time, i.e. not necessarily at the start of the stream - this is useful if you have an undetermined number of contigs to write to ACE, e.g: for my $contig (@list_of_contigs) { $ass_io->_write_contig($contig); } $ass_io->_write_header(); Returns : 1 on success, 0 for error Args : A Bio::Assembly::Scaffold or an arrayref of Bio::Assembly::Contig or nothing (the header is dynamically written based on the ACE file content) |
Title : write_footer Usage : $ass_io->write_footer($scaffold) Function: Write ACE footer (WA and CT tags). Returns : 1 on success, 0 for error Args : A Bio::Assembly::Scaffold object (optional) |
Title : _write_read Usage : $ass_io->_write_read($read, $contig) Function: Write a read object in ACE compatible format Returns : 1 on success, 0 for error Args : a Bio::LocatableSeq read the Contig or Singlet object that this read belongs to |
Title : _formatted_seq Usage : Bio::Assembly::IO::ace::_formatted_seq($sequence, $line_width) Function: Format a sequence for ACE output: i ) replace gaps in the sequence by the '*' char ii) split the sequence on multiple lines as needed Returns : new sequence string Args : sequence string on one line maximum line width |
Title : _formatted_qual Usage : Bio::Assembly::IO::ace::_formatted_qual($qual_arr, $sequence, $line_width, $qual_default) Function: Format quality scores for ACE output: i ) use the default quality values when they are missing ii ) remove gaps (they get no score in ACE) iii) split the quality scores on several lines as needed Returns : new quality score string Args : quality score array reference corresponding sequence string maximum line width default quality score |
Title : _input_qual Usage : Bio::Assembly::IO::ace::_input_qual($qual_string, $sequence) Function: Reads input quality string and converts it to an array of quality scores. Gaps get a quality score equals to the average of the quality score of its neighbours. Returns : new quality score array Args : quality score string corresponding sequence string |
Title : _initialize Usage : $ass_io->_initialize(@args) Function: Initialize the Bio::Assembly::IO object with the proper ACE variant Returns : Args : |
Methods code
sub next_assembly
{ my $self = shift;
my $assembly = Bio::Assembly::Scaffold->new();
while ( my $obj = $self->next_contig() ) {
if ($obj->isa('Bio::Assembly::Singlet')) { $assembly->add_singlet($obj);
} else { $assembly->add_contig($obj);
}
}
$self->scaffold_annotations($assembly);
return $assembly;} |
sub next_contig
{ my ($self) = shift;
local $/ = "\n";
my $contigOBJ;
my $read_name;
my $min_start;
my $read_data = {};
while ( $_ = $self->_readline) {
chomp;
if (/^CO\s(\S+)\s(\d+)\s(\d+)\s(\d+)\s(\w+)/xms) {
if (not $contigOBJ) {
my $contigID = $1; my $nof_reads = $3; my $ori = $5; $ori = $ori eq 'U' ? 1 : -1;
if ($nof_reads == 1) { $contigOBJ = Bio::Assembly::Singlet->new( );
} elsif ( $nof_reads > 1 ) { $contigOBJ = Bio::Assembly::Contig->new( );
}
$contigOBJ->id($contigID);
$contigOBJ->strand($ori);
my $consensus_sequence;
while ($_ = $self->_readline) { chomp; last if (/^$/); s/\*/-/g; $consensus_sequence .= $_;
}
$consensus_sequence = Bio::LocatableSeq->new(
-seq => $consensus_sequence,
-start => 1,
-strand => $ori,
);
$consensus_sequence->id($contigID);
$contigOBJ->set_consensus_sequence($consensus_sequence);
} else {
$self->_pushback($_);
last;
}
}
elsif (/^BQ/) {
my $qual_string = '';
while ($_ = $self->_readline) {
chomp;
last if (/^$/);
$qual_string .= "$_ ";
}
my @qual_arr = $self->_input_qual($qual_string, $contigOBJ->get_consensus_sequence->seq);
my $qual = Bio::Seq::PrimaryQual->new(-qual => join(" ", @qual_arr),
-id => $contigOBJ->id() );
$contigOBJ->set_consensus_quality($qual);
}
elsif (/^AF (\S+) (C|U) (-*\d+)/) {
$read_name = $1; my $ori = $2; my $start = $3;
$ori = $ori eq 'U' ? 1 : -1;
$read_data->{$read_name}{'strand'} = $ori;
$read_data->{$read_name}{'padded_start'} = $start;
if ( $self->variant eq '454' ) {
if ( (not defined $min_start) || ($start < $min_start) ) {
$min_start = $start;
}
}
}
elsif (/^BS (\d+) (\d+) (\S+)/) {
my ($start, $end, $contig_id) = ($1, $2, $3);
if ($self->variant eq '454') {
$start += abs($min_start) + 1;
$end += abs($min_start) + 1;
}
my $bs_feat = Bio::SeqFeature::Generic->new(
-start => $start,
-end => $end,
-source => 'ace',
-strand => 1,
-primary => '_base_segments',
-tag => { 'contig_id' => $contig_id}
);
$contigOBJ->add_features([ $bs_feat ], 0);
}
elsif (/^RD (\S+) (-*\d+) (\d+) (\d+)/) {
$read_name = $1;
$read_data->{$read_name}{'length'} = $2; $read_data->{$read_name}{'contig'} = $contigOBJ;
my $read_sequence;
while ($_ = $self->_readline) {
chomp;
last if (/^$/);
s/\*/-/g; $read_sequence .= $_; }
my $read = Bio::LocatableSeq->new(
-seq => $read_sequence,
-start => 1,
-strand => $read_data->{$read_name}{'strand'},
-id => $read_name,
-primary_id => $read_name,
-alphabet => 'dna'
);
my $padded_start = $read_data->{$read_name}{'padded_start'};
if ($self->variant eq '454') {
$padded_start += abs($min_start) + 1;
}
my $padded_end = $padded_start + $read_data->{$read_name}{'length'} - 1;
my $coord = Bio::SeqFeature::Generic->new(
-start => $padded_start,
-end => $padded_end,
-source => 'ace',
-strand => $read_data->{$read_name}{'strand'},
-tag => { 'contig' => $contigOBJ->id }
);
if ($contigOBJ->isa('Bio::Assembly::Singlet')) {
$contigOBJ->seqref($read);
} else { $contigOBJ->set_seq_coord($coord,$read);
}
}
elsif (/^QA (-?\d+) (-?\d+) (-?\d+) (-?\d+)/) {
my ($qual_start, $qual_end, $aln_start, $aln_end) =
($1, $2, $3, $4);
unless ($aln_start == -1 && $aln_end == -1) {
$aln_start = $contigOBJ->change_coord("aligned $read_name",'gapped consensus',$aln_start);
$aln_end = $contigOBJ->change_coord("aligned $read_name",'gapped consensus',$aln_end);
my $aln_feat = Bio::SeqFeature::Generic->new(
-start => $aln_start,
-end => $aln_end,
-strand => $read_data->{$read_name}{'strand'},
-primary => '_align_clipping',
-source => $read_name,
);
$aln_feat->attach_seq( $contigOBJ->get_seq_by_name($read_name) );
$contigOBJ->add_features([ $aln_feat ], 0);
}
unless ($qual_start == -1 && $qual_end == -1) {
$qual_start = $contigOBJ->change_coord("aligned $read_name",'gapped consensus',$qual_start);
$qual_end = $contigOBJ->change_coord("aligned $read_name",'gapped consensus',$qual_end);
my $qual_feat = Bio::SeqFeature::Generic->new(
-start => $qual_start,
-end => $qual_end,
-strand => $read_data->{$read_name}{'strand'},
-primary => '_quality_clipping',
-source => $read_name || '',
);
$qual_feat->attach_seq( $contigOBJ->get_seq_by_name($read_name) );
$contigOBJ->add_features([ $qual_feat ], 0);
}
}
elsif (/^DS\s+(.*)/) {
my $desc = $1;
my (undef, %tags) = split /\s?(\S+):\s+/, $desc;
my $coord = $contigOBJ->get_seq_coord( $contigOBJ->get_seq_by_name($read_name) );
my $start = $coord->start;
my $end = $coord->end;
my $read_desc = Bio::SeqFeature::Generic->new(
-start => $start,
-end => $end,
-primary => '_read_desc', -source => $read_name || '',
-tag =>\% tags
);
$contigOBJ->get_features_collection->add_features([$read_desc]);
$contigOBJ->get_features_collection->add_SeqFeature($coord, $read_desc);
}
elsif (/^RT\s*\{/) {
my ($readID,$type,$source,$start,$end,$date) = split(' ',$self->_readline);
my $extra_info = undef;
while ($_ = $self->_readline) {
last if (/\}/);
$extra_info .= $_;
}
$start = $contigOBJ->change_coord("aligned $readID",'gapped consensus',$start);
$end = $contigOBJ->change_coord("aligned $readID",'gapped consensus',$end);
my $read_tag = Bio::SeqFeature::Generic->new(
-start => $start,
-end => $end,
-primary => '_read_tags',
-source => $readID || '',
-tag => { 'type' => $type,
'source' => $source,
'creation_date' => $date}
);
$read_tag->add_tag_value('extra_info', $extra_info) if defined $extra_info;
my $contig = $read_data->{$readID}{'contig'};
my $coord = $contig->get_seq_coord( $contig->get_seq_by_name($readID) );
$contig->get_features_collection->add_features([$read_tag]);
$contig->get_features_collection->add_SeqFeature($coord, $read_tag);
}
}
if (($self->variant eq '454') && (defined $contigOBJ)) {
my $pad_char = '-';
my $pad_score = 0;
my $max_end;
for my $readid ($contigOBJ->get_seq_ids) {
my ($alncoord) = $contigOBJ->get_features_collection->get_features_by_type("_aligned_coord:$readid");
my $end = $alncoord->location->end;
if ( (not defined $max_end) || ($end > $max_end) ) {
$max_end = $end;
}
}
my $cons_seq = $contigOBJ->get_consensus_sequence;
my $cons_string = $cons_seq->seq;
my $l_pad_len = abs($min_start) + 1;
my $r_pad_len = $max_end - length($cons_string) - $l_pad_len;
$cons_string = $pad_char x $l_pad_len . $cons_string . $pad_char x $r_pad_len;
$cons_seq = Bio::LocatableSeq->new(
-seq => $cons_string,
-id => $cons_seq->id,
-start => $cons_seq->start,
-strand => $cons_seq->strand,
);
$contigOBJ->set_consensus_sequence($cons_seq);
my $cons_qual = $contigOBJ->get_consensus_quality;
if (defined $cons_qual) {
my $cons_score = [ ($pad_score) x $l_pad_len,
@{$cons_qual->qual},
($pad_score) x $r_pad_len ];
$cons_qual = Bio::Seq::PrimaryQual->new(
-qual => join(' ', @$cons_score),
-id => $cons_qual->id
);
$contigOBJ->set_consensus_quality($cons_qual);
}
}
return $contigOBJ;} |
sub scaffold_annotations
{ my ($self, $assembly) = @_;
local $/ = "\n";;
seek($self->_fh, 0, 0);
while ($_ = $self->_readline) {
chomp;
/^WA\s*\{/ && do {
my ($type,$source,$date) = split(' ',$self->_readline);
my $extra_info = undef;
while ($_ = $self->_readline) {
last if (/\}/);
$extra_info .= $_;
}
my $assembly_tags = join(" ","TYPE:",$type,"PROGRAM:",$source,
"DATE:",$date,"DATA:",$extra_info);
$assembly_tags = Bio::Annotation::SimpleValue->new(-value=>$assembly_tags);
$assembly->annotation->add_Annotation('whole assembly',$assembly_tags);
};
/^CT\s*\{/ && do {
my ($contigID,$type,$source,$start,$end,$date) = split(' ',$self->_readline);
my %tags = ('source' => $source, 'creation_date' => $date);
my $tag_type = 'extra_info';
while ($_ = $self->_readline) {
if (/COMMENT\s*\{/) {
$tag_type = 'comment';
} elsif (/C\}/) {
$tag_type = 'extra_info';
} elsif (/\}/) {
last;
} else {
$tags{$tag_type} .= "$_";
}
}
my $contig_tag = Bio::SeqFeature::Generic->new( -start => $start,
-end => $end,
-primary => $type,
-source => 'ace',
-tag =>\% tags );
my $contig = $assembly->get_contig_by_id($contigID) ||
$assembly->get_singlet_by_id($contigID);
$self->throw("Cannot add feature to unknown contig '$contigID'")
unless defined $contig;
$contig->add_features([ $contig_tag ],1);
};
}
return 1;} |
sub write_contig
{ my ($self, @args) = @_;
my ($contig) = $self->_rearrange([qw(CONTIG)], @args);
if ( !$contig || !$contig->isa('Bio::Assembly::Contig') ) {
$self->throw("Must provide a Bio::Assembly::Contig or Singlet object when calling write_contig");
}
my $contig_id = $contig->id;
my $cons = $contig->get_consensus_sequence;
my $cons_seq = $cons->seq;
my $cons_len = $cons->length;
my $contig_num_reads = $contig->num_sequences;
my $cons_strand = ($contig->strand == -1) ? 'C' : 'U';
my @bs_feats = $contig->get_features_collection->get_features_by_type('_base_segments');
my $nof_segments = scalar @bs_feats;
$self->_print(
"CO $contig_id $cons_len $contig_num_reads $nof_segments $cons_strand\n".
_formatted_seq($cons_seq, $line_width).
"\n"
);
$cons = $contig->get_consensus_quality;
my $cons_qual = $cons->qual if defined $cons;
$self->_print(
"BQ\n".
_formatted_qual($cons_qual, $cons_seq, $line_width, $qual_value).
"\n"
);
my @reads = $contig->each_seq;
for my $read (@reads) {
my $read_id = $read->id;
my $read_strand = ($read->strand == -1) ? 'C' : 'U';
my $read_start = $contig->change_coord("aligned $read_id",'gapped consensus',1);
$self->_print( "AF $read_id $read_strand $read_start\n" );
}
$self->_print( "\n" );
if ( @bs_feats ) {
@bs_feats = sort { $a->start <=> $b->start } @bs_feats;
for my $bs_feat ( @bs_feats ) {
my $start = $bs_feat->start;
my $end = $bs_feat->end;
my $id = ($bs_feat->get_tag_values('contig_id'))[0];
$self->_print( "BS $start $end $id\n" );
}
$self->_print( "\n" );
}
for my $read (@reads) {
$self->_write_read($read, $contig);
}
return 1;} |
sub write_header
{ my ($self, $input) = @_;
my @contigs;
my $err_msg = "If an input is given to write_header, it must be a single ".
"Bio::Assembly::Scaffold object or an arrayref of Bio::Assembly::Contig".
" or Singlet objects";
my $ref = ref $input;
if ( $ref eq 'ARRAY' ) {
for my $obj ( @$input ) {
$self->throw($err_msg) if not $obj->isa('Bio::Assembly::Contig');
push @contigs, $obj;
}
} elsif ( $ref =~ m/Bio::Assembly::Scaffold/ ) { @contigs = ($input->all_contigs, $input->all_singlets); }
my $num_contigs = 0;
my $num_reads = 0;
if ( scalar @contigs > 0 ) {
$num_contigs = scalar @contigs;
for my $contig ( @contigs ) {
$num_reads += $contig->num_sequences;
}
} else {
$self->flush;
my $file = $self->file(); $file =~ s/^\+?[><]?//; my $read_io = Bio::Assembly::IO->new( -file => $file, -format => 'ace' );
while ( my $contig = $read_io->next_contig ) {
$num_contigs++;
$num_reads += $contig->num_sequences;
}
$read_io->close;
}
my $header = "AS $num_contigs $num_reads\n\n";
$self->_insert($header, 1);
return 1;} |
sub write_footer
{ my ($self, $scaf) = @_;
return 1 if not defined $scaf;
if ($scaf->isa('Bio::Assembly:ScaffoldI')) {
$self->throw("Must provide a Bio::Assembly::Scaffold object when calling write_footer");
}
my $asm_anno = ($scaf->annotation->get_Annotations('whole assembly'))[0];
if ($asm_anno) {
my $asm_tags = $asm_anno->value;
if ($asm_tags =~ m/^TYPE: (\S+) PROGRAM: (\S+) DATE: (\S+) DATA: (.*)$/ms) { my ($type, $program, $date, $data) = ($1, $2, $3, $4); $data ||= '';
$self->_print(
"WA{\n".
"$type $program $date\n".
$data.
"}\n".
"\n"
);
}
}
for my $contig_id ( Bio::Assembly::IO::_sort( $scaf->get_contig_ids ) ) {
my $contig = $scaf->get_contig_by_id($contig_id) ||
$scaf->get_singlet_by_id($contig_id);
my @feats = (grep
{ not $_->primary_tag =~ m/^_/ } $contig->get_features_collection->features ); for my $feat (@feats) {
my $type = $feat->primary_tag;
my $start = $feat->start;
my $end = $feat->end;
my $source = ($feat->get_tag_values('source') )[0];
my $date = ($feat->get_tag_values('creation_date'))[0];
my $extra = '';
if ($feat->has_tag('extra_info')) {
$extra = ($feat->get_tag_values('extra_info') )[0];
}
$self->_print(
"CT{\n".
"$contig_id $type $source $start $end $date\n".
$extra.
"}\n".
"\n"
);
}
}
return 1;} |
sub _write_read
{ my ($self, @args) = @_;
my ($read, $contig) = $self->_rearrange([qw(READ CONTIG)], @args);
if ( !$read || !$read->isa('Bio::LocatableSeq') ) {
$self->throw("Must provide a Bio::LocatableSeq when calling write_read");
}
if ( !$contig || !$contig->isa('Bio::Assembly::Contig') ) {
$self->throw("Must provide a Bio::Assembly::Contig or Singlet object when calling write_read");
}
my $read_id = $read->id;
my $read_len = $read->length; my $read_seq = $read->seq;
my $nof_info = 0; my @read_tags = $contig->get_features_collection->get_SeqFeatures(
$contig->get_seq_coord($read), "_read_tags:$read_id");
my $nof_tags = scalar @read_tags;
$self->_print(
"RD $read_id $read_len $nof_info $nof_tags\n".
_formatted_seq($read_seq, $line_width).
"\n"
);
my $qual_clip_start = 1;
my $qual_clip_end = length($read->seq);
my ($qual_clip) = $contig->get_features_collection->get_features_by_type("_quality_clipping:$read_id");
if ( defined $qual_clip ) {
$qual_clip_start = $qual_clip->location->start;
$qual_clip_end = $qual_clip->location->end;
$qual_clip_start = $contig->change_coord('gapped consensus',"aligned $read_id",$qual_clip_start);
$qual_clip_end = $contig->change_coord('gapped consensus',"aligned $read_id",$qual_clip_end );
}
my $aln_clip_start = 1;
my $aln_clip_end = length($read->seq);
my ($aln_clip) = $contig->get_features_collection->get_features_by_type("_align_clipping:$read_id");
if ( defined $aln_clip ) {
$aln_clip_start = $aln_clip->location->start;
$aln_clip_end = $aln_clip->location->end;
$aln_clip_start = $contig->change_coord('gapped consensus',"aligned $read_id",$aln_clip_start );
$aln_clip_end = $contig->change_coord('gapped consensus',"aligned $read_id",$aln_clip_end );
}
$self->_print(
"QA $qual_clip_start $qual_clip_end $aln_clip_start $aln_clip_end\n".
"\n"
);
my $read_desc = ( $contig->get_features_collection->get_SeqFeatures(
$contig->get_seq_coord($read), "_read_desc:$read_id") )[0];
if ($read_desc) {
$self->_print("DS");
for my $tag_name ( $read_desc->get_all_tags ) {
my $tag_value = ($read_desc->get_tag_values($tag_name))[0];
$self->_print(" $tag_name: $tag_value");
}
$self->_print("\n\n");
}
for my $read_tag (@read_tags) {
my $start = $read_tag->start;
my $end = $read_tag->end;
my $type = ($read_tag->get_tag_values('type') )[0];
my $source = ($read_tag->get_tag_values('source') )[0];
my $date = ($read_tag->get_tag_values('creation_date'))[0];
my $extra = $read_tag->has_tag('extra_info') ?
($read_tag->get_tag_values('extra_info') )[0] : '';
$self->_print(
"RT{\n".
"$read_id $type $source $start $end $date\n".
$extra.
"}\n".
"\n"
);
}
return 1;} |
sub _formatted_seq
{ my ($seq_str, $line_width) = @_;
my $new_str = '';
$seq_str =~ s/-/*/g;
while ( my $chunk = substr $seq_str, 0, $line_width, '' ) {
$new_str .= "$chunk\n";
}
return $new_str;} |
sub _formatted_qual
{ my ($qual_arr, $seq, $line_width, $qual_default) = @_;
my $qual_str = '';
my @qual_arr;
if (defined $qual_arr) {
@qual_arr = @$qual_arr;
} else {
@qual_arr = map( $qual_default, (1 .. length $seq) );
}
my $gap_pos = -1;
while ( 1 ) {
$gap_pos = index($seq, '-', $gap_pos + 1);
last if $gap_pos == -1;
substr $seq, $gap_pos, 1, '';
splice @qual_arr, $gap_pos, 1;
$gap_pos--;
}
while ( my @chunks = splice @qual_arr, 0, $line_width ) {
$qual_str .= "@chunks\n";
}
return $qual_str;} |
sub _input_qual
{ my ($self, $qual_string, $sequence) = @_;
my @qual_arr = ();
$qual_string =~ s/^\s+//;
my @tmp = split(/\s+/, $qual_string);
my $i = 0; my $j = 0; my $prev = 0;
my $next = 0;
for $j (0 .. length($sequence)-1) {
my $nt = substr($sequence, $j, 1);
if ($nt eq '-') {
if ($i > 0) {
$prev = $tmp[$i-1];
} else {
$prev = 0;
}
if ($i < $#tmp) {
$next = $tmp[$i];
} else {
$next = 0;
}
push @qual_arr, int(($prev+$next)/2); } else {
push @qual_arr, $tmp[$i];
$i++;
}
}
return @qual_arr;} |
sub _initialize
{ my($self, @args) = @_;
$self->SUPER::_initialize(@args);
my ($variant) = $self->_rearrange([qw(VARIANT)], @args);
$variant ||= 'consed';
$self->variant($variant);
}
1;
__END__} |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing lists Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the web:
https://redmine.open-bio.org/projects/bioperl/
| AUTHOR - Robson Francisco de Souza | Top |
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
Title : write_assembly
Usage : $ass_io->write_assembly($assembly)
Function: Write the assembly object in ACE compatible format. The contig IDs
are sorted naturally if the Sort::Naturally module is present, or
lexically otherwise. Internally, write_assembly use the
write_contig, write_footer and write_header methods. Use these
methods if you want more control on the writing process.
Returns : 1 on success, 0 for error
Args : A Bio::Assembly::Scaffold object
Title : variant
Usage : $variant = $ass_io->variant();
Function: Get and set method for the assembly variant. This is important since
not all assemblers respect the reference ACE format.
Returns : string
Args : string: 'consed' (default) or '454'