view release on metacpan or search on metacpan
Though a stable release, some bugs and enhancements remain for this series
that will be addressed in future point releases. For a full list please see:
https://github.com/bioperl/bioperl-live/issues
Bug Summary (additional info)
2247 Have Bio::SearchIO::blast methods available for other BLAST parsers
(enhancement request)
2332 Software for analysis of redundant fragments of affys human mitochip v2
(API hasn't stabilized, may appear in a 1.6 point release)
2439 multiple results HTMLResultWriter.pm and non-redundant entries in SearchIO
(partially implemented)
2463 bp_seqconvert.pl & Bio::SeqIO code cleanup and user friendly interface
(enhancement request)
2476 "Undefined sub-sequence" when processing tblastx output
(related to HSP tiling)
2482 paml4 mlc file fails to parse
(may require refactoring Bio::Tools::Phylo::PAML)
2492 Method "pi" in package Bio::PopGen::Statistics
Bio/Assembly/Tools/ContigSpectrum.pm view on Meta::CPAN
An assembly can be produced from a mixture of sequences from different
metagenomes. The contig obtained from this assembly is a mixed contig
spectrum. The contribution of each metagenome in this mixed contig
spectrum can be obtained by determining a dissolved contig spectrum.
Finally, based on a mixed contig spectrum, a cross contig spectrum can
be determined. In a cross contig spectrum, only contigs containing
sequences from different metagenomes are kept; "pure" contigs are
excluded. Additionally, the total number of singletons (1-contigs)
from each region that assembles with any fragments from other regions
is the number of 1-contigs in the cross contig spectrum.
=head2 Implementation
The simplest representation of a contig spectrum is as a hash
representation where the key is the contig size (number of sequences
making up the contig) and the value the number of contigs of this
size.
In fact, it is useful to have more information associated with the
Bio/DB/GFF.pm view on Meta::CPAN
sequence similarity hits, and miscellaneous notes. See the next
section for a description of how to describe similarity targets.
The format of the group fields is "Class ID" with a single space (not
a tab) separating the class from the ID. It is VERY IMPORTANT to
follow this format, or grouping will not work properly.
=back
The sequences used to establish the coordinate system for annotations
can correspond to sequenced clones, clone fragments, contigs or
super-contigs. Thus, this module can be used throughout the lifecycle
of a sequencing project.
In addition to a group ID, the GFF format allows annotations to have a
group class. For example, in the ACeDB representation, RNA
interference experiments have a class of "RNAi" and an ID that is
unique among the RNAi experiments. Since not all databases support
this notion, the class is optional in all calls to this module, and
defaults to "Sequence" when not provided.
Bio/DB/GFF.pm view on Meta::CPAN
-off,-len Aliases for -offset and -length
-seqclass Alias for -class
Here's an example to explain how this works:
my $db = Bio::DB::GFF->new(-dsn => 'dbi:mysql:human',-adaptor=>'dbi::mysql');
If successful, $db will now hold the database accessor object. We now
try to fetch the fragment of sequence whose ID is A0000182 and class
is "Accession."
my $segment = $db->segment(-name=>'A0000182',-class=>'Accession');
If successful, $segment now holds the entire segment corresponding to
this accession number. By default, the sequence is used as its own
reference sequence, so its first base will be 1 and its last base will
be the length of the accession.
Assuming that this sequence belongs to a longer stretch of DNA, say a
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
$sth = $self->dbh->do_query('select fdna,foffset from fdna where fref=? and foffset>=? order by foffset',
$ref,$offset_start);
}
else { # both start and stop defined
$sth = $self->dbh->do_query('select fdna,foffset from fdna where fref=? and foffset>=? and foffset<=? order by foffset',
$ref,$offset_start,$offset_stop);
}
my $dna = '';
while (my($frag,$offset) = $sth->fetchrow_array) {
substr($frag,0,$start-$offset) = '' if $has_start && $start > $offset;
$dna .= $frag;
}
substr($dna,$stop-$start+1) = '' if $has_stop && $stop-$start+1 < length($dna);
if ($reversed) {
$dna = reverse $dna;
$dna =~ tr/gatcGATC/ctagCTAG/;
}
$sth->finish;
$dna;
}
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
while (my ($c) = $sth->fetchrow_array) {
push @classes,$c;
}
@classes;
}
=head2 make_classes_query
Title : make_classes_query
Usage : ($query,@args) = $db->make_classes_query
Function: return query fragment for generating list of reference classes
Returns : a query and args
Args : none
Status : public
=cut
sub make_classes_query {
my $self = shift;
return;
}
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
($q1,@args) = make_types_select_part(@args);
($q2,@args) = make_types_from_part(@args);
($q3,@args) = make_types_where_part(@args);
($q4,@args) = make_types_join_part(@args);
($q5,@args) = make_types_group_part(@args);
The components are then combined as follows:
$query = "SELECT $q1 FROM $q2 WHERE $q3 AND $q4 GROUP BY $q5";
If any of the query fragments contain the ? bind variable, then the
same number of bind arguments must be provided in @args. The
fragment-generating functions are described below.
=cut
sub get_types {
my $self = shift;
my ($srcseq,$class,$start,$stop,$want_count,$typelist) = @_;
my $straight = $self->do_straight_join($srcseq,$start,$stop,[]) ? 'straight_join' : '';
my ($select,@args1) = $self->make_types_select_part($srcseq,$start,$stop,$want_count,$typelist);
my ($from,@args2) = $self->make_types_from_part($srcseq,$start,$stop,$want_count,$typelist);
my ($join,@args3) = $self->make_types_join_part($srcseq,$start,$stop,$want_count,$typelist);
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
to similarly-named arguments passed to range_query().
=cut
sub do_straight_join { 0 } # false by default
=head2 string_match
Title : string_match
Usage : $string = $db->string_match($field,$value)
Function: create a SQL fragment for performing exact or regexp string matching
Returns : query string
Args : the table field and match value
Status : public
This method examines the passed value for meta characters. If so it
produces a SQL fragment that performs a regular expression match.
Otherwise, it produces a fragment that performs an exact string match.
This method is not used in the module, but is available for use by
subclasses.
=cut
sub string_match {
my $self = shift;
my ($field,$value) = @_;
return qq($field = ?) if $value =~ /^[!@%&a-zA-Z0-9_\'\" ~-]+$/;
return qq($field REGEXP ?);
}
=head2 exact_match
Title : exact_match
Usage : $string = $db->exact_match($field,$value)
Function: create a SQL fragment for performing exact string matching
Returns : query string
Args : the table field and match value
Status : public
This method produces the SQL fragment for matching a field name to a
constant string value.
=cut
sub exact_match {
my $self = shift;
my ($field,$value) = @_;
return qq($field = ?);
}
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
Usage : $value = $db->meta($name [,$newval])
Function: get or set a meta variable
Returns : a string
Args : meta variable name and optionally value
Status : public
Get or set a named metavariable for the database. Metavariables can
be used for database-specific settings. This method calls two
class-specific methods which must be implemented:
make_meta_get_query() Returns a sql fragment which given a meta
parameter name, returns its value. One bind
variable.
make_meta_set_query() Returns a sql fragment which takes two bind
arguments, the parameter name and its value
Don't make changes unless you know what you're doing! It will affect the
persistent database.
=cut
sub meta {
my $self = shift;
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
$sth->finish;
return $self->{meta}{$param_name} = $value;
}
}
=head2 make_meta_get_query
Title : make_meta_get_query
Usage : $sql = $db->make_meta_get_query
Function: return SQL fragment for getting a meta parameter
Returns : SQL fragment
Args : none
Status : public
By default this does nothing; meta parameters are not stored or
retrieved.
=cut
sub make_meta_get_query {
return 'SELECT fvalue FROM fmeta WHERE fname=?';
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
sub dna_chunk_size {
my $self = shift;
$self->meta('chunk_size') || DNA_CHUNK_SIZE;
}
=head2 make_meta_set_query
Title : make_meta_set_query
Usage : $sql = $db->make_meta_set_query
Function: return SQL fragment for setting a meta parameter
Returns : SQL fragment
Args : none
Status : public
By default this does nothing; meta parameters are not stored or
retrieved.
=cut
sub make_meta_set_query {
return;
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
sub clone {
my $self = shift;
$self->features_db->clone;
}
=head1 QUERIES TO IMPLEMENT
The following astract methods either return DBI statement handles or
fragments of SQL. They must be implemented by subclasses of this
module. See Bio::DB::GFF::Adaptor::dbi::mysql for examples.
=head2 drop_other_schema_objects
Title : drop_other_schema_objects
Usage : $self->create_other_schema_objects($table_name)
Function: create other schema objects like : indexes, sequences, triggers
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
#########################################
## Moved from mysql.pm and mysqlopt.pm ##
#########################################
=head2 make_features_by_name_where_part
Title : make_features_by_name_where_part
Usage : $db->make_features_by_name_where_part
Function: create the SQL fragment needed to select a feature by its group name & class
Returns : a SQL fragment and bind arguments
Args : see below
Status : Protected
=cut
sub make_features_by_name_where_part {
my $self = shift;
my ($class,$name) = @_;
if ($name =~ /\*/) {
$name =~ s/%/\\%/g;
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
push @sql,"(fattribute.fattribute_name=? AND fattribute_to_feature.fattribute_value=?)";
push @args,($_,$attributes->{$_});
}
return (join(' OR ',@sql),@args);
}
=head2 make_features_by_id_where_part
Title : make_features_by_id_where_part
Usage : $db->make_features_by_id_where_part($ids)
Function: create the SQL fragment needed to select a set of features by their ids
Returns : a SQL fragment and bind arguments
Args : arrayref of IDs
Status : Protected
=cut
sub make_features_by_id_where_part {
my $self = shift;
my $ids = shift;
my $set = join ",",@$ids;
return ("fdata.fid IN ($set)");
}
=head2 make_features_by_gid_where_part
Title : make_features_by_id_where_part
Usage : $db->make_features_by_gid_where_part($ids)
Function: create the SQL fragment needed to select a set of features by their ids
Returns : a SQL fragment and bind arguments
Args : arrayref of IDs
Status : Protected
=cut
sub make_features_by_gid_where_part {
my $self = shift;
my $ids = shift;
my $set = join ",",@$ids;
return ("fgroup.gid IN ($set)");
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
AND fattribute.fattribute_id=fattribute_to_feature.fattribute_id
AND fdata.fid=fattribute_to_feature.fid
END2
}
=head2 make_features_order_by_part
Title : make_features_order_by_part
Usage : ($query,@args) = $db->make_features_order_by_part()
Function: make the ORDER BY part of the features() query
Returns : a SQL fragment and bind arguments, if any
Args : none
Status : protected
This method creates the part of the features query that immediately
follows the ORDER BY part of the query issued by features() and
related methods.
=cut
sub make_features_order_by_part {
my $self = shift;
my $options = shift || {};
return "fgroup.gname";
}
=head2 make_features_group_by_part
Title : make_features_group_by_part
Usage : ($query,@args) = $db->make_features_group_by_part()
Function: make the GROUP BY part of the features() query
Returns : a SQL fragment and bind arguments, if any
Args : none
Status : protected
This method creates the part of the features query that immediately
follows the GROUP BY part of the query issued by features() and
related methods.
=cut
sub make_features_group_by_part {
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
elsif (my $b = $options->{bin_width}) {
return "fref,fstart,fdata.ftypeid";
}
}
=head2 refseq_query
Title : refseq_query
Usage : ($query,@args) = $db->refseq_query($name,$class)
Function: create SQL fragment that selects the desired reference sequence
Returns : a list containing the query and bind arguments
Args : reference sequence name and class
Status : protected
This method is called by make_features_by_range_where_part() to
construct the part of the select WHERE section that selects a
particular reference sequence. It returns a mult-element list in
which the first element is the SQL fragment and subsequent elements
are bind values.
For example:
sub refseq_query {
my ($name,$class) = @_;
return ('gff.refseq=? AND gff.refclass=?',
$name,$class);
}
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
$sth->finish;
return @result;
}
=head2 overlap_query_nobin
Title : overlap_query
Usage : ($query,@args) = $db->overlap_query($start,$stop)
Function: create SQL fragment that selects the desired features by range
Returns : a list containing the query and bind arguments
Args : the start and stop of a range, inclusive
Status : protected
This method is called by make_features_byrange_where_part() to construct the
part of the select WHERE section that selects a set of features that
overlap a range. It returns a multi-element list in which the first
element is the SQL fragment and subsequent elements are bind values.
sub overlap_query_nobin {
my ($start,$stop) = @_;
return ('gff.stopE<gt>=? AND gff.startE<lt>=?',
$start,$stop);
=cut
# find features that overlap a given range
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
my ($start,$stop) = @_;
my $query = qq(fdata.fstop>=? AND fdata.fstart<=?);
return wantarray ? ($query,$start,$stop) : $self->dbh->dbi_quote($query,$start,$stop);
}
=head2 contains_query_nobin
Title : contains_query
Usage : ($query,@args) = $db->contains_query_nobin($start,$stop)
Function: create SQL fragment that selects the desired features by range
Returns : a list containing the query and bind arguments
Args : the start and stop of a range, inclusive
Status : protected
This method is called by make_features_byrange_where_part() to construct the
part of the select WHERE section that selects a set of features
entirely enclosed by a range. It returns a multi-element list in which
the first element is the SQL fragment and subsequent elements are bind
values. For example:
sub contains_query_nobin {
my ($start,$stop) = @_;
return ('gff.start>=? AND gff.stop<=?',
$start,$stop);
=cut
# find features that are completely contained within a range
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
my $self = shift;
my ($start,$stop) = @_;
my $query = qq(fdata.fstart>=? AND fdata.fstop<=?);
return wantarray ? ($query,$start,$stop) : $self->dbh->dbi_quote($query,$start,$stop);
}
=head2 contained_in_query_nobin
Title : contained_in_query_nobin
Usage : ($query,@args) = $db->contained_in_query($start,$stop)
Function: create SQL fragment that selects the desired features by range
Returns : a list containing the query and bind arguments
Args : the start and stop of a range, inclusive
Status : protected
This method is called by make_features_byrange_where_part() to construct the
part of the select WHERE section that selects a set of features
entirely enclosed by a range. It returns a multi-element list in which
the first element is the SQL fragment and subsequent elements are bind
values.For example:
sub contained_in_query_nobin {
my ($start,$stop) = @_;
return ('gff.start<=? AND gff.stop>=?',
$start,$stop);
}
=cut
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
my $self = shift;
my ($start,$stop) = @_;
my $query = qq(fdata.fstart<=? AND fdata.fstop>=?);
return wantarray ? ($query,$start,$stop) : $self->dbh->dbi_quote($query,$start,$stop);
}
=head2 types_query
Title : types_query
Usage : ($query,@args) = $db->types_query($types)
Function: create SQL fragment that selects the desired features by type
Returns : a list containing the query and bind arguments
Args : an array reference containing the types
Status : protected
This method is called by make_features_byrange_where_part() to construct the
part of the select WHERE section that selects a set of features based
on their type. It returns a multi-element list in which the first
element is the SQL fragment and subsequent elements are bind values.
The argument is an array reference containing zero or more
[$method,$source] pairs.
=cut
# generate the fragment of SQL responsible for searching for
# features with particular types and methods
sub types_query {
my $self = shift;
my $types = shift;
my @method_queries;
my @args;
for my $type (@$types) {
my ($method,$source) = @$type;
my ($mlike, $slike) = (0, 0);
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
=head2 make_types_select_part
Title : make_types_select_part
Usage : ($string,@args) = $db->make_types_select_part(@args)
Function: create the select portion of the SQL for fetching features type list
Returns : query string and bind arguments
Args : see below
Status : protected
This method is called by get_types() to generate the query fragment
and bind arguments for the SELECT part of the query that retrieves
lists of feature types. The four positional arguments are as follows:
$refseq reference sequence name
$start start of region
$stop end of region
$want_count true to return the count of this feature type
If $want_count is false, the SQL fragment returned must produce a list
of feature types in the format (method, source).
If $want_count is true, the returned fragment must produce a list of
feature types in the format (method, source, count).
=cut
#------------------------- support for the types() query ------------------------
sub make_types_select_part {
my $self = shift;
my ($srcseq,$start,$stop,$want_count) = @_;
my $query = $want_count ? 'ftype.fmethod,ftype.fsource,count(fdata.ftypeid)'
: 'fmethod,fsource';
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
=head2 make_types_from_part
Title : make_types_from_part
Usage : ($string,@args) = $db->make_types_from_part(@args)
Function: create the FROM portion of the SQL for fetching features type lists
Returns : query string and bind arguments
Args : see below
Status : protected
This method is called by get_types() to generate the query fragment
and bind arguments for the FROM part of the query that retrieves lists
of feature types. The four positional arguments are as follows:
$refseq reference sequence name
$start start of region
$stop end of region
$want_count true to return the count of this feature type
If $want_count is false, the SQL fragment returned must produce a list
of feature types in the format (method, source).
If $want_count is true, the returned fragment must produce a list of
feature types in the format (method, source, count).
=cut
sub make_types_from_part {
my $self = shift;
my ($srcseq,$start,$stop,$want_count) = @_;
my $query = defined($srcseq) || $want_count ? 'fdata,ftype' : 'ftype';
return $query;
}
=head2 make_types_join_part
Title : make_types_join_part
Usage : ($string,@args) = $db->make_types_join_part(@args)
Function: create the JOIN portion of the SQL for fetching features type lists
Returns : query string and bind arguments
Args : see below
Status : protected
This method is called by get_types() to generate the query fragment
and bind arguments for the JOIN part of the query that retrieves lists
of feature types. The four positional arguments are as follows:
$refseq reference sequence name
$start start of region
$stop end of region
$want_count true to return the count of this feature type
=cut
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
=head2 make_types_where_part
Title : make_types_where_part
Usage : ($string,@args) = $db->make_types_where_part(@args)
Function: create the WHERE portion of the SQL for fetching features type lists
Returns : query string and bind arguments
Args : see below
Status : protected
This method is called by get_types() to generate the query fragment
and bind arguments for the WHERE part of the query that retrieves
lists of feature types. The four positional arguments are as follows:
$refseq reference sequence name
$start start of region
$stop end of region
$want_count true to return the count of this feature type
=cut
Bio/DB/GFF/Adaptor/dbi.pm view on Meta::CPAN
=head2 make_types_group_part
Title : make_types_group_part
Usage : ($string,@args) = $db->make_types_group_part(@args)
Function: create the GROUP BY portion of the SQL for fetching features type lists
Returns : query string and bind arguments
Args : see below
Status : protected
This method is called by get_types() to generate the query fragment
and bind arguments for the GROUP BY part of the query that retrieves
lists of feature types. The four positional arguments are as follows:
$refseq reference sequence name
$start start of region
$stop end of region
$want_count true to return the count of this feature type
=cut
Bio/DB/GFF/Adaptor/dbi/mysql.pm view on Meta::CPAN
=item fdna
This table holds the raw DNA of the reference sequences. It has three
columns:
fref reference sequence name (string)
foffset offset of this sequence
fdna the DNA sequence (longblob)
To overcome problems loading large blobs, DNA is automatically
fragmented into multiple segments when loading, and the position of
each segment is stored in foffset. The fragment size is controlled by
the -clump_size argument during initialization.
=item fattribute_to_feature
This table holds "attributes", which are tag/value pairs stuffed into
the GFF line. The first tag/value pair is treated as the group, and
anything else is treated as an attribute (weird, huh?).
CHR_I assembly_tag Finished 2032 2036 . + . Note "Right: cTel33B"
CHR_I assembly_tag Polymorphism 668 668 . + . Note "A->C in cTel33B"
Bio/DB/GFF/Adaptor/dbi/mysql.pm view on Meta::CPAN
);
return \%schema;
}
=head2 make_classes_query
Title : make_classes_query
Usage : ($query,@args) = $db->make_classes_query
Function: return query fragment for generating list of reference classes
Returns : a query and args
Args : none
Status : public
=cut
sub make_classes_query {
my $self = shift;
return 'SELECT DISTINCT gclass FROM fgroup WHERE NOT ISNULL(gclass)';
}
=head2 make_meta_set_query
Title : make_meta_set_query
Usage : $sql = $db->make_meta_set_query
Function: return SQL fragment for setting a meta parameter
Returns : SQL fragment
Args : none
Status : public
By default this does nothing; meta parameters are not stored or
retrieved.
=cut
sub make_meta_set_query {
return 'REPLACE INTO fmeta VALUES (?,?)';
Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
=item fdna
This table holds the raw DNA of the reference sequences. It has three
columns:
fref reference sequence name (string)
foffset offset of this sequence
fdna the DNA sequence (longblob)
To overcome problems loading large blobs, DNA is automatically
fragmented into multiple segments when loading, and the position of
each segment is stored in foffset. The fragment size is controlled by
the -clump_size argument during initialization.
=item fattribute_to_feature
This table holds "attributes", which are tag/value pairs stuffed into
the GFF line. The first tag/value pair is treated as the group, and
anything else is treated as an attribute (weird, huh?).
CHR_I assembly_tag Finished 2032 2036 . + . Note "Right: cTel33B"
CHR_I assembly_tag Polymorphism 668 668 . + . Note "A->C in cTel33B"
Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
);
return \%schema;
}
=head2 make_classes_query
Title : make_classes_query
Usage : ($query,@args) = $db->make_classes_query
Function: return query fragment for generating list of reference classes
Returns : a query and args
Args : none
Status : public
=cut
sub make_classes_query {
my $self = shift;
return 'SELECT DISTINCT gclass FROM cmap_feature WHERE NOT ISNULL(gclass)';
}
Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
}
#-----------------------------------
=head2 make_features_by_name_where_part
Title : make_features_by_name_where_part
Usage : $db->make_features_by_name_where_part
Function: create the SQL fragment needed to select a feature by its group name & class
Returns : a SQL fragment and bind arguments
Args : see below
Status : Protected
=cut
sub make_features_by_name_where_part {
my $self = shift;
my ($class,$name) = @_;
if ($name =~ /\*/) {
$name =~ tr/*/%/;
Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
# push @results,[$featname,$note,$relevance];
# }
# @results;
# }
=head2 make_features_order_by_part
Title : make_features_order_by_part
Usage : ($query,@args) = $db->make_features_order_by_part()
Function: make the ORDER BY part of the features() query
Returns : a SQL fragment and bind arguments, if any
Args : none
Status : protected
This method creates the part of the features query that immediately
follows the ORDER BY part of the query issued by features() and
related methods.
=cut
sub make_features_order_by_part {
Bio/DB/GFF/Adaptor/dbi/oracle.pm view on Meta::CPAN
=item fdna
This table holds the raw DNA of the reference sequences. It has three
columns:
fref reference sequence name (string)
foffset offset of this sequence
fdna the DNA sequence (longblob)
To overcome problems loading large blobs, DNA is automatically
fragmented into multiple segments when loading, and the position of
each segment is stored in foffset. The fragment size is controlled by
the -clump_size argument during initialization.
=item fattribute_to_feature
This table holds "attributes", which are tag/value pairs stuffed into
the GFF line. The first tag/value pair is treated as the group, and
anything else is treated as an attribute (weird, huh?).
CHR_I assembly_tag Finished 2032 2036 . + . Note "Right: cTel33B"
CHR_I assembly_tag Polymorphism 668 668 . + . Note "A->C in cTel33B"
Bio/DB/GFF/Adaptor/dbi/oracle.pm view on Meta::CPAN
push @results,[$featname,$note,$relevance,$type];
last if $limit && @results >= $limit;
}
@results;
}
=head2 make_meta_set_query
Title : make_meta_set_query
Usage : $sql = $db->make_meta_set_query
Function: return SQL fragment for setting a meta parameter
Returns : SQL fragment
Args : none
Status : public
By default this does nothing; meta parameters are not stored or
retrieved.
=cut
sub make_meta_set_query {
return 'INSERT INTO fmeta VALUES (?,?)';
Bio/DB/GFF/Adaptor/dbi/pg.pm view on Meta::CPAN
=item fdna
This table holds the raw DNA of the reference sequences. It has three
columns:
fref reference sequence name (string)
foffset offset of this sequence
fdna the DNA sequence (longblob)
To overcome problems loading large blobs, DNA is automatically
fragmented into multiple segments when loading, and the position of
each segment is stored in foffset. The fragment size is controlled by
the -clump_size argument during initialization.
=item fattribute_to_feature
This table holds "attributes", which are tag/value pairs stuffed into
the GFF line. The first tag/value pair is treated as the group, and
anything else is treated as an attribute (weird, huh?).
CHR_I assembly_tag Finished 2032 2036 . + . Note "Right: cTel33B"
CHR_I assembly_tag Polymorphism 668 668 . + . Note "A->C in cTel33B"
Bio/DB/GFF/Adaptor/dbi/pg.pm view on Meta::CPAN
# warn @results;
#
# return @results;
}
=head2 make_meta_set_query
Title : make_meta_set_query
Usage : $sql = $db->make_meta_set_query
Function: return SQL fragment for setting a meta parameter
Returns : SQL fragment
Args : none
Status : public
By default this does nothing; meta parameters are not stored or
retrieved.
=cut
sub make_meta_set_query {
return 'INSERT INTO fmeta VALUES (?,?)';
Bio/DB/GFF/Adaptor/dbi/pg.pm view on Meta::CPAN
1;
}
=head2 make_features_by_name_where_part
Title : make_features_by_name_where_part
Usage : $db->make_features_by_name_where_part
Function: Overrides a function in Bio::DB::GFF::Adaptor::dbi to insure
that searches will be case insensitive. It creates the SQL
fragment needed to select a feature by its group name & class
Returns : a SQL fragment and bind arguments
Args : see below
Status : Protected
=cut
sub make_features_by_name_where_part {
my $self = shift;
my ($class,$name) = @_;
if ($name !~ /\*/) {
Bio/DB/GFF/Adaptor/dbi/pg.pm view on Meta::CPAN
$sth = $self->dbh->do_query('select fdna,foffset from fdna where lower(fref)=lower(?) and foffset>=? order by foffset',
$ref,$offset_start);
}
else { # both start and stop defined
$sth = $self->dbh->do_query('select fdna,foffset from fdna where lower(fref)=lower(?) and foffset>=? and foffset<=? order by foffset',
$ref,$offset_start,$offset_stop);
}
my $dna = '';
while (my($frag,$offset) = $sth->fetchrow_array) {
substr($frag,0,$start-$offset) = '' if $has_start && $start > $offset;
$dna .= $frag;
}
substr($dna,$stop-$start+1) = '' if $has_stop && $stop-$start+1 < length($dna);
if ($reversed) {
$dna = reverse $dna;
$dna =~ tr/gatcGATC/ctagCTAG/;
}
$sth->finish;
$dna;
}
Bio/DB/SeqFeature/Store.pm view on Meta::CPAN
=head2 insert_sequence
Title : insert_sequence
Usage : $success = $db->insert_sequence($seqid,$sequence_string,$offset)
Function: Inserts sequence data into the database at the indicated offset
Returns : true if successful
Args : see below
Status : public
This method inserts the DNA or protein sequence fragment
$sequence_string, identified by the ID $seq_id, into the database at
the indicated offset $offset. It is used internally by the GFF3Loader
to load sequence data from the files.
=cut
###
# insert_sequence()
#
# insert a bit of primary sequence into the database
Bio/DB/SeqFeature/Store/DBI/Pg.pm view on Meta::CPAN
WHERE s.id=ll.id
AND ll.seqname= ?
AND "offset" >= ?
AND "offset" <= ?
ORDER BY "offset"
END
my $seq = '';
$sth->execute($seqid,$offset1,$offset2) or $self->throw($sth->errstr);
while (my($frag,$offset) = $sth->fetchrow_array) {
substr($frag,0,$start-$offset) = '' if defined $start && $start > $offset;
$seq .= $frag;
}
substr($seq,$end-$start+1) = '' if defined $end && $end-$start+1 < length($seq);
if ($reversed) {
$seq = reverse $seq;
$seq =~ tr/gatcGATC/ctagCTAG/;
}
$sth->finish;
$seq;
}
Bio/DB/SeqFeature/Store/DBI/SQLite.pm view on Meta::CPAN
WHERE ll.id=s.id
AND ll.seqname= ?
AND offset >= ?
AND offset <= ?
ORDER BY offset
END
my $seq = '';
$sth->execute($seqid,$offset1,$offset2) or $self->throw($sth->errstr);
while (my($frag,$offset) = $sth->fetchrow_array) {
substr($frag,0,$start-$offset) = '' if defined $start && $start > $offset;
$seq .= $frag;
}
substr($seq,$end-$start+1) = '' if defined $end && $end-$start+1 < length($seq);
if ($reversed) {
$seq = reverse $seq;
$seq =~ tr/gatcGATC/ctagCTAG/;
}
$sth->finish;
$seq;
}
Bio/DB/SeqFeature/Store/DBI/mysql.pm view on Meta::CPAN
AND s.offset >= ?
AND s.offset <= ?
ORDER BY s.offset
END
my $sth = $self->_prepare($sql);
my $seq = '';
$self->_print_query($sql,$id,$offset1,$offset2) if DEBUG || $self->debug;
$sth->execute($id,$offset1,$offset2) or $self->throw($sth->errstr);
while (my($frag,$offset) = $sth->fetchrow_array) {
substr($frag,0,$start-$offset) = '' if defined $start && $start > $offset;
$seq .= $frag;
}
substr($seq,$end-$start+1) = '' if defined $end && $end-$start+1 < length($seq);
if ($reversed) {
$seq = reverse $seq;
$seq =~ tr/gatcGATC/ctagCTAG/;
}
$sth->finish;
$seq;
}
Bio/DB/SeqFeature/Store/FeatureFileLoader.pm view on Meta::CPAN
yk53c10.3 15000-15500,15700-15800
yk53c10.5 18892-19154
This example is declaring that the ESTs named yk53c10.3 and yk53c10.5
belong to the same group named yk53c10.
=head2 Comments and the #include Directive
Lines that begin with the # sign are treated as comments and
ignored. When a # sign appears within a line, everything to the right
of the symbol is also ignored, unless it looks like an HTML fragment or
an HTML color, e.g.:
# this is ignored
[Example]
glyph = generic # this comment is ignored
bgcolor = #FF0000
link = http://www.google.com/search?q=$name#results
Be careful, because the processing of # signs uses a regexp heuristic. To be safe,
always put a space after the # sign to make sure it is treated as a comment.
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
$sv = Bio::Annotation::SimpleValue->new(-tagname => 'relative_end', -value => $data[5] || ($data[4] || 1 + length($data[2]) - 1));
$annot->add_Annotation($sv);
$sv = Bio::Annotation::SimpleValue->new(-tagname => 'relative_type', -value => $data[3] || 'artificial');
$annot->add_Annotation($sv);
$sv = Bio::Annotation::SimpleValue->new(-tagname => 'relative_to', -value => $data[1]);
$annot->add_Annotation($sv);
return $seq;
}
=head2 get_fragment
Title : get_fragment
Usage : my $seq = $obj->get_fragment($id);
Function: Get the sequence of a fragment.
Returns : Bio::Seq
Args : string - a site id ('FR...')
=cut
sub get_fragment {
my ($self, $id) = @_;
$id || return;
my $data = $self->{fragment}->{data}->{$id} || return;
my @data = split(SEPARATOR, $data);
# accession = id gene_id1 gene_id2 species_tax_id_or_raw_string sequence source
return new Bio::Seq( -seq => $data[4],
-accession_number => $id,
-description => 'Between genes '.$data[1].' and '.$data[2],
-species => $data[3],
-id => $data[0],
-alphabet => 'dna' );
}
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
-id -name -species -interactors -gene -matrix -site -reference
NB: -gene only gets factor ids for genes that encode factors
=cut
sub get_factor_ids {
my $self = shift;
return $self->_get_ids('factor', @_);
}
=head2 get_fragment_ids
Title : get_fragment_ids
Usage : my @ids = $obj->get_fragment_ids(-key => $value);
Function: Get all the fragment ids that are associated with the supplied
args.
Returns : list of strings (ids)
Args : -key => value, where value is a string id, and key is one of:
-id -species -gene -factor -reference
=cut
sub get_fragment_ids {
my $self = shift;
return $self->_get_ids('fragment', @_);
}
=head2 Helper methods
=cut
# internal method which does the indexing
sub _build_index {
my ($self, $dat_dir, $force) = @_;
# MLDBM would give us transparent complex data structures with DB_File,
# allowing just one index file, but its yet another requirement and we
# don't strictly need it
my $index_dir = $self->index_directory;
my $gene_index = "$index_dir/gene.dat.index";
my $reference_index = "$index_dir/reference.dat.index";
my $matrix_index = "$index_dir/matrix.dat.index";
my $factor_index = "$index_dir/factor.dat.index";
my $fragment_index = "$index_dir/fragment.dat.index";
my $site_index = "$index_dir/site.dat.index";
my $reference_dat = "$dat_dir/reference.dat";
if (! -e $reference_index || $force) {
open my $REF, '<', $reference_dat or $self->throw("Could not read reference file '$reference_dat': $!");
my %references;
unlink $reference_index;
my $ref = tie(%references, 'DB_File', $reference_index, O_RDWR|O_CREAT, 0644, $DB_HASH)
or $self->throw("CCould not open file '$reference_index': $!");
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
unlink $reference_gene;
my $gene = tie(%gene, 'DB_File', $reference_gene, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$reference_gene': $!");
my %site;
my $reference_site = $site_index.'.reference';
unlink $reference_site;
my $site = tie(%site, 'DB_File', $reference_site, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$reference_site': $!");
my %fragment;
my $reference_fragment = $fragment_index.'.reference';
unlink $reference_fragment;
my $fragment = tie(%fragment, 'DB_File', $reference_fragment, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$reference_fragment': $!");
my %factor;
my $reference_factor = $factor_index.'.reference';
unlink $reference_factor;
my $factor = tie(%factor, 'DB_File', $reference_factor, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$reference_factor': $!");
my %matrix;
my $reference_matrix = $matrix_index.'.reference';
unlink $reference_matrix;
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
elsif (/^GE TRANSFAC: (\w\d+)/) {
$gene->put($data[0], "$1");
}
elsif (/^BS TRANSFAC: (\w\d+)/) {
$site->put($data[0], "$1");
}
elsif (/^FA TRANSFAC: (\w\d+)/) {
$factor->put($data[0], "$1");
}
elsif (/^FR TRANSFAC: (FR\d+)/) {
$fragment->put($data[0], "$1");
}
elsif (/^MX TRANSFAC: (\w\d+)/) {
$matrix->put($data[0], "$1");
}
elsif (/^\/\//) {
# end of a record, store previous data and reset
# accession = pubmed authors title location
$references{$data[0]} = join(SEPARATOR, ($data[1] || '',
$data[2] || '',
$data[3] || '',
$data[4] || ''));
@data = ();
}
}
close $REF;
$ref = $pub = $gene = $site = $fragment = $factor = $matrix = undef;
untie %references;
untie %pubmed;
untie %gene;
untie %site;
untie %fragment;
untie %factor;
untie %matrix;
}
my $gene_dat = "$dat_dir/gene.dat";
if (! -e $gene_index || $force) {
open my $GEN, '<', $gene_dat or $self->throw("Could not read gene file '$gene_dat': $!");
my %genes;
unlink $gene_index;
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
unlink $gene_site;
my $site = tie(%site, 'DB_File', $gene_site, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$gene_site': $!");
my %factor;
my $gene_factor = $factor_index.'.gene';
unlink $gene_factor;
my $factor = tie(%factor, 'DB_File', $gene_factor, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$gene_factor': $!");
my %fragment;
my $gene_fragment = $fragment_index.'.gene';
unlink $gene_fragment;
my $fragment = tie(%fragment, 'DB_File', $gene_fragment, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$gene_fragment': $!");
my %reference;
my $gene_reference = $reference_index.'.gene';
unlink $gene_reference;
my $reference = tie(%reference, 'DB_File', $gene_reference, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$gene_reference': $!");
# skip the first three header lines
<$GEN>; <$GEN>; <$GEN>;
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
elsif (/^RN .+?(RE\d+)/) {
$reference->put($data[0], "$1");
}
elsif (/^BS .+?(R\d+)/) {
$site->put($data[0], "$1");
}
elsif (/^FA (T\d+)/) {
$factor->put($data[0], "$1");
}
elsif (/^BR (FR\d+)/) {
$fragment->put($data[0], "$1");
}
elsif (/^\/\//) {
# end of a record, store previous data and reset
# accession = id name description species_tax_id_or_raw_string
$genes{$data[0]} = join(SEPARATOR, ($data[1] || '',
$data[2] || '',
$data[3] || '',
$data[4] || ''));
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
unlink $factor_matrix;
my $matrix = tie(%matrix, 'DB_File', $factor_matrix, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$factor_matrix': $!");
my %site;
my $factor_site = $site_index.'.factor';
unlink $factor_site;
my $site = tie(%site, 'DB_File', $factor_site, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$factor_site': $!");
my %fragment;
my $factor_fragment = $fragment_index.'.factor';
unlink $factor_fragment;
my $fragment = tie(%fragment, 'DB_File', $factor_fragment, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$factor_fragment': $!");
my %reference;
my $factor_reference = $reference_index.'.factor';
unlink $factor_reference;
my $reference = tie(%reference, 'DB_File', $factor_reference, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$factor_reference': $!");
# skip the first three header lines
<$FAC>; <$FAC>; <$FAC>;
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
elsif (/^IN (T\d+)/) {
$interact->put($data[0], "$1");
}
elsif (/^MX (M\d+)/) {
$matrix->put($data[0], "$1");
}
elsif (/^BS (R\d+)/) {
$site->put($data[0], "$1");
}
elsif (/^BR (FR\d+)/) {
$fragment->put($data[0], "$1");
}
elsif (/^RN .+?(RE\d+)/) {
$reference->put($data[0], "$1");
}
elsif (/^\/\//) {
# end of a record, store previous data and reset
# accession = id name species sequence
$factors{$data[0]} = join(SEPARATOR, ($data[1] || '',
$data[2] || '',
$data[3] || '',
$sequence));
@data = ();
$sequence = '';
}
}
close $FAC;
$factor = $id = $name = $species = $interact = $gene = $matrix = $site = $fragment = $reference = undef;
untie %factors;
untie %id;
untie %name;
untie %species;
untie %interactors;
untie %gene;
untie %matrix;
untie %site;
untie %fragment;
untie %reference;
}
my $fragment_dat = "$dat_dir/fragment.dat";
if (! -e $fragment_index || $force) {
if (open my $FRA, '<', $fragment_dat) {
my %fragments;
unlink $fragment_index;
my $fragment = tie(%fragments, 'DB_File', $fragment_index, O_RDWR|O_CREAT, 0644, $DB_HASH)
or $self->throw("Could not open file '$fragment_index': $!");
my %id;
my $fragment_id = $fragment_index.'.id';
unlink $fragment_id;
my $id = tie(%id, 'DB_File', $fragment_id, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$fragment_id': $!");
my %qualities;
my $fragment_qualities = $fragment_index.'.qual';
unlink $fragment_qualities;
my $quality = tie(%qualities, 'DB_File', $fragment_qualities, O_RDWR|O_CREAT, 0644, $DB_HASH)
or $self->throw("Could not open file '$fragment_qualities': $!");
my %species;
my $fragment_species = $fragment_index.'.species';
unlink $fragment_species;
my $species = tie(%species, 'DB_File', $fragment_species, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$fragment_species': $!");
my %gene;
my $fragment_gene = $gene_index.'.fragment';
unlink $fragment_gene;
my $gene = tie(%gene, 'DB_File', $fragment_gene, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$fragment_gene': $!");
my %factor;
my $fragment_factor = $factor_index.'.fragment';
unlink $fragment_factor;
my $factor = tie(%factor, 'DB_File', $fragment_factor, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$fragment_factor': $!");
my %reference;
my $fragment_reference = $reference_index.'.fragment';
unlink $fragment_reference;
my $reference = tie(%reference, 'DB_File', $fragment_reference, O_RDWR|O_CREAT, 0644, $DB_BTREE)
or $self->throw("Could not open file '$fragment_reference': $!");
# skip the first three header lines
<$FRA>; <$FRA>; <$FRA>;
my @data;
while (<$FRA>) {
if (/^AC (\S+)/) {
$data[0] = $1;
}
elsif (/^ID (\S+)/) {
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
$reference->put($data[0], "$1");
}
elsif (/^BF (T\d+); .+?; Quality: (\d)/) {
$factor->put($data[0], "$1");
$qualities{$data[0].SEPARATOR.$1} = $2;
}
elsif (/^\/\//) {
# end of a record, store previous data and reset
# accession = id gene_id1 gene_id2 species_tax_id_or_raw_string sequence source
$fragments{$data[0]} = join(SEPARATOR, ($data[1] || '',
$data[2] || '',
$data[3] || '',
$data[4] || '',
$data[5] || '',
$data[6] || ''));
@data = ();
}
}
close $FRA;
$fragment = $id = $species = $quality = $gene = $factor = $reference = undef;
untie %fragments;
untie %id;
untie %species;
untie %qualities;
untie %gene;
untie %factor;
untie %reference;
}
else {
$self->warn("Could not read fragment file '$fragment_dat', assuming you have an old version of Transfac Pro with no fragment.dat file");
}
}
}
# connect the internal db handle
sub _db_connect {
my $self = shift;
return if $self->{'_initialized'};
my $index_dir = $self->index_directory;
my $gene_index = "$index_dir/gene.dat.index";
my $reference_index = "$index_dir/reference.dat.index";
my $matrix_index = "$index_dir/matrix.dat.index";
my $factor_index = "$index_dir/factor.dat.index";
my $site_index = "$index_dir/site.dat.index";
my $fragment_index = "$index_dir/fragment.dat.index";
foreach ($gene_index, $reference_index, $matrix_index, $factor_index, $site_index, $fragment_index) {
if (! -e $_) {
#$self->warn("Index files have not been created");
#return 0;
}
}
# reference
{
$self->{reference}->{data} = {};
tie (%{$self->{reference}->{data}}, 'DB_File', $reference_index, O_RDWR, undef, $DB_HASH) || $self->throw("Cannot open file '$reference_index': $!");
my $reference_pubmed = $reference_index.'.pubmed';
$self->{reference}->{pubmed} = tie (%{$self->{reference}->{pubmed}}, 'DB_File', $reference_pubmed, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$reference_pubmed': $!");
my $reference_gene = $gene_index.'.reference';
$self->{gene}->{reference} = tie (%{$self->{gene}->{reference}}, 'DB_File', $reference_gene, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$reference_gene': $!");
my $reference_site = $site_index.'.reference';
$self->{site}->{reference} = tie (%{$self->{site}->{reference}}, 'DB_File', $reference_site, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$reference_site': $!");
my $reference_fragment = $fragment_index.'.reference';
$self->{fragment}->{reference} = tie (%{$self->{fragment}->{reference}}, 'DB_File', $reference_fragment, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$reference_fragment': $!");
my $reference_factor = $factor_index.'.reference';
$self->{factor}->{reference} = tie (%{$self->{factor}->{reference}}, 'DB_File', $reference_factor, undef, 0644, $DB_BTREE) || $self->throw("Cannot open file '$reference_factor': $!");
my $reference_matrix = $matrix_index.'.reference';
$self->{matrix}->{reference} = tie (%{$self->{matrix}->{reference}}, 'DB_File', $reference_matrix, undef, 0644, $DB_BTREE) || $self->throw("Cannot open file '$reference_matrix': $!");
}
# gene
{
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
my $gene_name = $gene_index.'.name';
$self->{gene}->{name} = tie(%{$self->{gene}->{name}}, 'DB_File', $gene_name, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_name': $!");
my $gene_species = $gene_index.'.species';
$self->{gene}->{species} = tie(%{$self->{gene}->{species}}, 'DB_File', $gene_species, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_species': $!");
my $gene_site = $site_index.'.gene';
$self->{site}->{gene} = tie(%{$self->{site}->{gene}}, 'DB_File', $gene_site, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_site': $!");
my $gene_fragment = $fragment_index.'.gene';
$self->{fragment}->{gene} = tie(%{$self->{fragment}->{gene}}, 'DB_File', $gene_fragment, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_fragment': $!");
my $gene_factor = $factor_index.'.gene';
$self->{factor}->{gene} = tie(%{$self->{factor}->{gene}}, 'DB_File', $gene_factor, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_factor': $!");
my $gene_reference = $reference_index.'.gene';
$self->{reference}->{gene} = tie(%{$self->{reference}->{gene}}, 'DB_File', $gene_reference, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$gene_reference': $!");
}
# site
{
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
my $site_matrix = $matrix_index.'.site';
$self->{matrix}->{site} = tie(%{$self->{matrix}->{site}}, 'DB_File', $site_matrix, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$site_matrix': $!");
my $site_factor = $factor_index.'.site';
$self->{factor}->{site} = tie(%{$self->{factor}->{site}}, 'DB_File', $site_factor, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$site_factor': $!");
my $site_reference = $reference_index.'.site';
$self->{reference}->{site} = tie(%{$self->{reference}->{site}}, 'DB_File', $site_reference, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$site_reference': $!");
}
# fragment (may not be in older databases)
if (-e $fragment_index) {
$self->{fragment}->{data} = {};
tie (%{$self->{fragment}->{data}}, 'DB_File', $fragment_index, O_RDWR, undef, $DB_HASH) || $self->throw("Cannot open file '$fragment_index': $!");
my $fragment_id = $fragment_index.'.id';
$self->{fragment}->{id} = tie(%{$self->{fragment}->{id}}, 'DB_File', $fragment_id, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$fragment_id': $!");
my $fragment_species = $fragment_index.'.species';
$self->{fragment}->{species} = tie(%{$self->{fragment}->{species}}, 'DB_File', $fragment_species, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file $fragment_species': $!");
#*** quality not actually used by anything (yet)
my $fragment_qualities = $fragment_index.'.qual';
$self->{fragment_quality} = {};
tie(%{$self->{fragment_quality}}, 'DB_File', $fragment_qualities, O_RDWR, undef, $DB_HASH) || $self->throw("Cannot open file '$fragment_qualities': $!");
my $fragment_gene = $gene_index.'.fragment';
$self->{gene}->{fragment} = tie(%{$self->{gene}->{fragment}}, 'DB_File', $fragment_gene, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$fragment_gene': $!");
my $fragment_factor = $factor_index.'.fragment';
$self->{factor}->{fragment} = tie(%{$self->{factor}->{fragment}}, 'DB_File', $fragment_factor, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$fragment_factor': $!");
my $fragment_reference = $reference_index.'.fragment';
$self->{reference}->{fragment} = tie(%{$self->{reference}->{fragment}}, 'DB_File', $fragment_reference, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$fragment_reference': $!");
}
else {
die "no fragment_index at '$fragment_index'\n";
}
# matrix
{
$self->{matrix}->{data} = {};
tie (%{$self->{matrix}->{data}}, 'DB_File', $matrix_index, O_RDWR, undef, $DB_HASH) || $self->throw("Cannot open file '$matrix_index': $!");
my $matrix_id = $matrix_index.'.id';
$self->{matrix}->{id} = tie(%{$self->{matrix}->{id}}, 'DB_File', $matrix_id, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$matrix_id': $!");
Bio/DB/TFBS/transfac_pro.pm view on Meta::CPAN
my $factor_gene = $gene_index.'.factor';
$self->{gene}->{factor} = tie(%{$self->{gene}->{factor}}, 'DB_File', $factor_gene, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$factor_gene': $!");
my $factor_matrix = $matrix_index.'.factor';
$self->{matrix}->{factor} = tie(%{$self->{matrix}->{factor}}, 'DB_File', $factor_matrix, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$factor_matrix': $!");
my $factor_site = $site_index.'.factor';
$self->{site}->{factor} = tie(%{$self->{site}->{factor}}, 'DB_File', $factor_site, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$factor_site': $!");
my $factor_fragment = $fragment_index.'.factor';
$self->{fragment}->{factor} = tie(%{$self->{fragment}->{factor}}, 'DB_File', $factor_fragment, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$factor_fragment': $!");
my $factor_reference = $reference_index.'.factor';
$self->{reference}->{factor} = tie(%{$self->{reference}->{factor}}, 'DB_File', $factor_reference, O_RDWR, undef, $DB_BTREE) || $self->throw("Cannot open file '$factor_reference': $!");
}
$self->{'_initialized'} = 1;
}
=head2 index_directory
Bio/Restriction/Analysis.pm view on Meta::CPAN
# find unique cutters. This returns a
# Bio::Restriction::EnzymeCollection object
my $enzymes = $ra->unique_cutters;
print "Unique cutters: ", join (', ',
map {$_->name} $enzymes->unique_cutters), "\n";
# AluI is one them. Where does it cut?
# This is will return an array of the sequence strings
my $enz = 'AluI';
my @frags = $ra->fragments($enz);
# how big are the fragments?
print "AluI fragment lengths: ", join(' & ', map {length $_} @frags), "\n";
# You can also bypass fragments and call sizes directly:
# to see all the fragment sizes
print "All sizes: ", join " ", $ra->sizes($enz), "\n";
# to see all the fragment sizes sorted by size like on a gel
print "All sizes, sorted ", join (" ", $ra->sizes($enz, 0, 1)), "\n";
# how many times does each enzyme cut
my $cuts = $ra->cuts_by_enzyme('BamHI');
print "BamHI cuts $cuts times\n";
# How many enzymes do not cut at all?
print "There are ", scalar $ra->zero_cutters->each_enzyme,
" enzymes that do not cut\n";
Bio/Restriction/Analysis.pm view on Meta::CPAN
like this:
use Bio::Restriction::Analysis;
my $ra = Bio::Restriction::Analysis->new(-seq=>$seqobj);
or
my $ra = Bio::Restriction::Analysis->new
(-seq=>$seqobj, -enzymes=>$enzs);
Then, to get the fragments for a particular enzyme use this:
@fragments = $ra->fragments('EcoRI');
Note that the naming of restriction enzymes is that the last numbers
are usually Roman numbers (I, II, III, etc). You may want to use
something like this:
# get a reference to an array of unique (single) cutters
$singles = $re->unique_cutters;
foreach my $enz ($singles->each_enzyme) {
@fragments = $re->fragments($enz);
... do something here ...
}
Note that if your sequence is circular, the first and last fragment
will be joined so that they are the appropriate length and sequence
for further analysis. This fragment will also be checked for cuts
by the enzyme(s). However, this will change the start of the
sequence!
There are two separate algorithms used depending on whether your
enzyme has ambiguity. The non-ambiguous algorithm is a lot faster,
and if you are using very large sequences you should try and use
this algorithm. If you have a large sequence (e.g. genome) and
want to use ambgiuous enzymes you may want to make separate
Bio::Restriction::Enzyme objects for each of the possible
alternatives and make sure that you do not set is_ambiguous!
This version should correctly deal with overlapping cut sites
in both ambiguous and non-ambiguous enzymes.
I have tried to write this module with speed and memory in mind
so that it can be effectively used for large (e.g. genome sized)
sequence. This module only stores the cut positions internally,
and calculates everything else on an as-needed basis. Therefore
when you call fragment_maps (for example), there may be another
delay while these are generated.
=head1 FEEDBACK
=head2 Mailing Lists
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.
Bio/Restriction/Analysis.pm view on Meta::CPAN
Returns : The Restriction::Analysis object
Arguments :
$re_anal->new(-seq=$seqobj,
-enzymes=>Restriction::EnzymeCollection object)
-seq requires a Bio::PrimarySeq object
-enzymes is optional.
If omitted it will use the default set of enzymes
This is the place to start. Pass in a sequence, and you will be able
to get the fragments back out. Several other things are available
like the number of zero cutters or single cutters.
=cut
sub new {
my($class, @args) = @_;
my $self = $class->SUPER::new(@args);
my ($seq,$enzymes) =
$self->_rearrange([qw(
SEQ
Bio/Restriction/Analysis.pm view on Meta::CPAN
# keep track of status
$self->{'_cut'} = 0;
# left these here because we want to reforce a _cut if someone
# just calls new
$self->{maximum_cuts} = 0;
$self->{'_number_of_cuts_by_enzyme'} = {};
$self->{'_number_of_cuts_by_cuts'} = {};
$self->{'_fragments'} = {};
$self->{'_cut_positions'} = {}; # cut position is the real position
$self->{'_frag_map_list'} = {};
return $self;
}
=head1 Methods to set parameters
=cut
=head2 seq
Bio/Restriction/Analysis.pm view on Meta::CPAN
unless $self->seq;
if ($opt && uc($opt) eq "MULTIPLE") {
$self->throw("You must supply a separate enzyme collection for multiple digests") unless $ec;
$self->_multiple_cuts($ec); # multiple digests
} else {
# reset some of the things that we save
$self->{maximum_cuts} = 0;
$self->{'_number_of_cuts_by_enzyme'} = {};
$self->{'_number_of_cuts_by_cuts'} = {};
$self->{'_fragments'} = {};
$self->{'_cut_positions'} = {}; # cut position is the real position
$self->{'_frag_map_list'} = {};
$self->_cuts;
}
$self->{'_cut'} = 1;
return $self;
}
=head2 multiple_digest
Title : multiple_digest
Bio/Restriction/Analysis.pm view on Meta::CPAN
my ($self, $enz) = @_;
$self->cut unless $self->{'_cut'};
$self->throw('no enzyme selected to get positions for')
unless $enz;
return defined $self->{'_cut_positions'}->{$enz} ?
@{$self->{'_cut_positions'}->{$enz}} :
();
}
=head2 fragments
Title : fragments
Function : Retrieve the fragments that we cut
Returns : An array of the fragments retrieved.
Arguments: An enzyme name to retrieve the fragments for
For example this code will retrieve the fragments for all enzymes that
cut your sequence
my $all_cutters = $analysis->cutters;
foreach my $enz ($$all_cutters->each_enzyme}) {
@fragments=$analysis->fragments($enz);
}
=cut
sub fragments {
my ($self, $enz) = @_;
$self->cut unless $self->{'_cut'};
$self->throw('no enzyme selected to get fragments for')
unless $enz;
my @fragments;
for ($self->fragment_maps($enz)) {push @fragments, $_->{seq}}
return @fragments;
}
=head2 fragment_maps
Title : fragment_maps
Function : Retrieves fragment sequences with start and end
points. Useful for feature construction.
Returns : An array containing a hash reference for each fragment,
containing the start point, end point and DNA
sequence. The hash keys are 'start', 'end' and
'seq'. Returns an empty array if not defined.
Arguments : An enzyme name, enzyme object,
or enzyme collection to retrieve the fragments for.
If passes an enzyme collection it will return the result of a multiple
digest. This : will also cause the special enzyme 'multiple_digest' to
be created so you can get : other information about this multiple
digest. (TMTOWTDI).
There is a minor problem with this and $self-E<gt>fragments that I
haven't got a good answer for (at the moment). If the sequence is not
cut, do we return undef, or the whole sequence?
For linear fragments it would be good to return the whole
sequence. For circular fragments I am not sure.
At the moment it returns the whole sequence with start of 1 and end of
length of the sequence. For example:
use Bio::Restriction::Analysis;
use Bio::Restriction::EnzymeCollection;
use Bio::PrimarySeq;
my $seq = Bio::PrimarySeq->new
(-seq =>'AGCTTAATTCATTAGCTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATCCAAAAAAGAGTGAGCTTCTGAT',
-primary_id => 'synopsis',
-molecule => 'dna');
my $ra = Bio::Restriction::Analysis->new(-seq=>$seq);
my @gel;
my @bam_maps = $ra->fragment_maps('BamHI');
foreach my $i (@bam_maps) {
my $start = $i->{start};
my $end = $i->{end};
my $sequence = $i->{seq};
push @gel, "$start--$sequence--$end";
@gel = sort {length $b <=> length $a} @gel;
}
print join("\n", @gel) . "\n";
=cut
sub fragment_maps {
my ($self, $enz) = @_;
$self->cut unless $self->{'_cut'};
$self->throw('no enzyme selected to get fragment maps for')
unless $enz;
# we are going to generate this on an as-needed basis rather than
# for every enzyme this should cut down on the amount of
# duplicated data we are trying to save in memory and make this
# faster and easier for large sequences, e.g. genome analysis
my @cut_positions;
if (ref $enz eq '' && exists $self->{'_cut_positions'}->{$enz}) {
@cut_positions=@{$self->{'_cut_positions'}->{$enz}};
Bio/Restriction/Analysis.pm view on Meta::CPAN
unless (defined($cut_positions[0])) {
# it doesn't cut
# return the whole sequence
# this should probably have the is_circular command
my %map=(
'start' => 1,
'end' => $self->{'_seq'}->length,
'seq' => $self->{'_seq'}->seq
);
push (@{$self->{'_frag_map_list'}->{$enz}}, \%map);
return defined $self->{'_frag_map_list'}->{$enz} ?
@{$self->{'_frag_map_list'}->{$enz}} : ();
}
@cut_positions=sort {$a <=> $b} @cut_positions;
push my @cuts, $cut_positions[0];
foreach my $i (@cut_positions) {
push @cuts, $i if $i != $cuts[$#cuts];
}
my $start=1; my $stop; my %seq; my %stop;
foreach $stop (@cuts) {
Bio/Restriction/Analysis.pm view on Meta::CPAN
if ($start > $stop) {
# borderline case. The enzyme cleaved at the end of the sequence
# what do I do now?
}
else {
$seq{$start}=$self->{'_seq'}->subseq($start, $stop);
$stop{$start}=$stop;
}
if ($self->{'_seq'}->is_circular) {
# join the first and last fragments
$seq{$start}.=$seq{'1'};
delete $seq{'1'};
$stop{$start}=$stop{'1'};
delete $stop{'1'};
}
foreach my $start (sort {$a <=> $b} keys %seq) {
my %map=(
'start' => $start,
'end' => $stop{$start},
'seq' => $seq{$start}
);
push (@{$self->{'_frag_map_list'}->{$enz}}, \%map);
}
return defined $self->{'_frag_map_list'}->{$enz} ?
@{$self->{'_frag_map_list'}->{$enz}} : ();
}
=head2 sizes
Title : sizes
Function : Retrieves an array with the sizes of the fragments
Returns : Array that has the sizes of the fragments ordered from
largest to smallest like they would appear in a gel.
Arguments: An enzyme name to retrieve the sizes for is required and
kilobases to the nearest 0.1 kb, else it will be in
bp. If the optional third entry is set the results will
be sorted.
This is designed to make it easy to see what fragments you should get
on a gel!
You should be able to do these:
# to see all the fragment sizes,
print join "\n", $re->sizes($enz), "\n";
# to see all the fragment sizes sorted
print join "\n", $re->sizes($enz, 0, 1), "\n";
# to see all the fragment sizes in kb sorted
print join "\n", $re->sizes($enz, 1, 1), "\n";
=cut
sub sizes {
my ($self, $enz, $kb, $sort) = @_;
$self->throw('no enzyme selected to get fragments for')
unless $enz;
if (blessed($enz)) {
$self->throw("Enzyme must be enzyme name or a Bio::Restriction::EnzymeI, not ".ref($enz))
if !$enz->isa('Bio::Restriction::EnzymeI');
$enz = $enz->name;
}
$self->cut unless $self->{'_cut'};
my @frag; my $lastsite=0;
foreach my $site (@{$self->{'_cut_positions'}->{$enz}}) {
$kb ? push (@frag, (int($site-($lastsite))/100)/10)
: push (@frag, $site-($lastsite));
$lastsite=$site;
}
$kb ? push (@frag, (int($self->{'_seq'}->length-($lastsite))/100)/10)
: push (@frag, $self->{'_seq'}->length-($lastsite));
if ($self->{'_seq'}->is_circular) {
my $first=shift @frag;
my $last=pop @frag;
push @frag, ($first+$last);
}
$sort ? @frag = sort {$b <=> $a} @frag : 1;
return @frag;
}
=head1 How many times does enzymes X cut?
=cut
=head2 cuts_by_enzyme
Title : cuts_by_enzyme
Function : Return the number of cuts for an enzyme
Bio/Restriction/Analysis.pm view on Meta::CPAN
if $i != ${$self->{'_cut_positions'}->{$enz->name}}[$#{$self->{'_cut_positions'}->{$enz->name}}];
}
} else {
# this just fixes an eror when @all_cuts is not defined!
@{$self->{'_cut_positions'}->{$enz->name}}=();
}
# note I have removed saving any other information except the
# cut_positions this should significantly decrease the amount
# of memory that is required for large sequences. It should
# also speed things up dramatically, because fragments and
# fragment maps are only calculated for those enzymes they are
# needed for.
# finally, save minimal information about each enzyme
my $number_of_cuts=scalar @{$self->{'_cut_positions'}->{$enz->name}};
# now just store the number of cuts
$self->{_number_of_cuts_by_enzyme}->{$enz->name}=$number_of_cuts;
push (@{$self->{_number_of_cuts_by_cuts}->{$number_of_cuts}}, $enz);
if ($number_of_cuts > $self->{maximum_cuts}) {
$self->{maximum_cuts}=$number_of_cuts;
}
Bio/Restriction/Analysis.pm view on Meta::CPAN
Status : NOW DEPRECATED - maj
=cut
sub _enzyme_sites {
my ($self, $enz, $comp )=@_;
# get the cut site
# I have reworked this so that it uses $enz->cut to get the site
my $site= ( $comp ? $enz->complementary_cut : $enz->cut );
# split it into the two fragments for the sequence before and after.
$site=0 unless defined $site;
# the default values just stop an error from an undefined
# string. But they don't affect the split.
my ($beforeseq, $afterseq)= ('.', '.');
# extra-site cutting
# the before seq is going to be the entire site
# the after seq is empty
# BUT, need to communicate how to cut within the sample sequence
Bio/Restriction/Analysis.pm view on Meta::CPAN
# element 0 sequence
# element 1 3' end
# element 2 5' end of next sequence
# element 3 sequence
# ....
# we need to loop through the array and add the ends to the
# appropriate parts of the sequence
my $i=0;
my @re_frags;
if ($#cuts) { # there is >1 element
while ($i<$#cuts) {
my $joinedseq;
# the first sequence is a special case
if ($i == 0) {
$joinedseq=$cuts[$i].$cuts[$i+1];
} else {
$joinedseq=$cuts[$i-1].$cuts[$i].$cuts[$i+1];
}
# now deal with overlapping sequences
# we can do this through a regular regexp as we only
# have a short fragment to look through
while ($joinedseq =~ /$beforeseq$afterseq/) {
$joinedseq =~ s/^(.*?$beforeseq)($afterseq)/$2/;
push @re_frags, $1;
}
push @re_frags, $joinedseq;
$i+=3;
}
# I don't think we want the last fragment in. It is messing up the _circular
# part of things. So I deleted this part of the code :)
} else {
# if we don't cut, leave the array empty
return [];
} # the sequence was not cut.
# now @re_frags has the fragments of all the sequences
# but some people want to have this return the lengths
# of the fragments.
# in theory the actual cut sites should be the length
# of the fragments in @re_frags
# note, that now this is the only data that we are saving. We
# will have to go back add regenerate re_frags. The reason is
# that we can use this in _circular easier
my @cut_positions = map {length($_)} @re_frags;
# the cut positions are right now the lengths of the sequence, but
# we need to add them all onto each other
for (my $i=1; $i<=$#cut_positions; $i++) {
$cut_positions[$i]+=$cut_positions[$i-1];
}
# in one of those oddities in life, 2 fragments mean an enzyme cut once
# so $#re_frags is the number of cuts
return \@cut_positions;
}
# new version/maj
sub _ambig_cuts {
my ($self, $before, $after, $target, $enz, $comp) = @_;
my $cut_site = ($comp ? $enz->complementary_cut : $enz->cut);
local $_ = uc $target;
my @cuts;
Bio/Restriction/Analysis.pm view on Meta::CPAN
Arguments : A Bio::Restriction::EnzymeCollection object
Comments : Double digests is one subset of this, but you can use
as many enzymes as you want.
=cut
sub _multiple_cuts {
my ($self, $ec)=@_;
$self->cut unless $self->{'_cut'};
# now that we are using positions rather than fragments
# this is really easy
my @cuts;
foreach my $enz ($ec->each_enzyme) {
push @cuts, @{$self->{'_cut_positions'}->{$enz->name}}
if defined $self->{'_cut_positions'}->{$enz->name};
}
@{$self->{'_cut_positions'}->{'multiple_digest'}}=sort {$a <=> $b} @cuts;
my $number_of_cuts;
Bio/Restriction/Analysis.pm view on Meta::CPAN
my $patch_len = ( length $target > 20 ? 10 : int( length($target)/2 ) );
my ($first, $last) =
(substr($target, 0, $patch_len),substr($target, -$patch_len));
my $patch=$last.$first;
# now find the cut sites
my $cut_positions = $self->_make_cuts($patch, $enz, $comp);
# the enzyme doesn't cut in the new fragment
return [] if (!$cut_positions);
# now we are going to add things to _cut_positions
# in this shema it doesn't matter if the site is there twice -
# we will take care of that later. Because we are using position
# rather than frag or anything else, we can just
# remove duplicates.
my @circ_cuts;
foreach my $cut (@$cut_positions) {
if ($cut == length($last)) {
# the cut is actually at position 0, but we're going to call this the
# length of the sequence so we don't confuse no cuts with a 0 cut
# push (@circ_cuts, $self->{'_seq'}->length);
push (@circ_cuts, 0);
}
Bio/Restriction/Enzyme.pm view on Meta::CPAN
Example : $re->cutter
Returns : integer or float number
Args : none
Why is this better than just stripping the ambiguos codes? Think about
it like this: You have a random sequence; all nucleotides are equally
probable. You have a four nucleotide re site. The probability of that
site finding a match is one out of 4^4 or 256, meaning that on average
a four cutter finds a match every 256 nucleotides. For a six cutter,
the average fragment length is 4^6 or 4096. In the case of ambiguity
codes the chances are finding the match are better: an R (A|T) has 1/2
chance of finding a match in a random sequence. Therefore, for RGCGCY
the probability is one out of (2*4*4*4*4*2) which exactly the same as
for a five cutter! Cutter, although it can have non-integer values
turns out to be a useful and simple measure.
From bug 2178: VHDB are ambiguity symbols that match three different
nucleotides, so they contribute less to the effective recognition sequence
length than e.g. Y which matches only two nucleotides. A symbol which matches n
of the 4 nucleotides has an effective length of 1 - log(n) / log(4).
Bio/Restriction/EnzymeI.pm view on Meta::CPAN
Example : $re->cutter
Returns : integer or float number
Args : none
Why is this better than just stripping the ambiguous codes? Think about
it like this: You have a random sequence; all nucleotides are equally
probable. You have a four nucleotide re site. The probability of that
site finding a match is one out of 4^4 or 256, meaning that on average
a four cutter finds a match every 256 nucleotides. For a six cutter,
the average fragment length is 4^6 or 4096. In the case of ambiguity
codes the chances are finding the match are better: an R (A|T) has 1/2
chance of finding a match in a random sequence. Therefore, for RGCGCY
the probability is one out of (2*4*4*4*4*2) which exactly the same as
for a five cutter! Cutter, although it can have non-integer values
turns out to be a useful and simple measure.
From bug 2178: VHDB are ambiguity symbols that match three different
nucleotides, so they contribute less to the effective recognition sequence
length than e.g. Y which matches only two nucleotides. A symbol which matches n
of the 4 nucleotides has an effective length of 1 - log(n) / log(4).
Bio/Search/Tiling/MapTiling.pm view on Meta::CPAN
@covering_hsps_for_subject = $tiling->next_tiling('subject',$context);
$context = $tiling->_context( -type => 'query', -strand=> -1, -frame=>0);
@covering_hsps_for_query = $tiling->next_tiling('query', $context);
=head1 DESCRIPTION
Frequently, users want to use a set of high-scoring pairs (HSPs)
obtained from a BLAST or other search to assess the overall level of
identity, conservation, or coverage represented by matches between a
subject and a query sequence. Because a set of HSPs frequently
describes multiple overlapping sequence fragments, a simple summation of
statistics over the HSPs will generally overestimate those
statistics. To obtain an accurate estimate of global hit statistics, a
'tiling' of HSPs onto either the subject or the query sequence must be
performed, in order to properly correct for this.
This module will execute a tiling algorithm on a given hit based on an
interval decomposition I'm calling the "coverage map". Internal object
methods compute the various statistics, which are then stored in
appropriately-named public object attributes. See
L<Bio::Search::Tiling::MapTileUtils> for more info on the algorithm.
Bio/Search/Tiling/MapTiling.pm view on Meta::CPAN
Each alignment contains two sequences with ids 'query' and 'subject',
and consists of a concatenation of tiling HSPs which overlap or are
directly adjacent. The alignment are returned in C<$type> sequence
order. When HSPs overlap, the alignment sequence is taken from the HSP
which comes first in the coverage map array.
The sequences in each alignment contain features (even though they are
L<Bio::LocatableSeq> objects) which map the original query/subject
coordinates to the new alignment sequence coordinates. You can
determine the original BLAST fragments this way:
$aln = ($tiling->get_tiled_alns)[0];
$qseq = $aln->get_seq_by_id('query');
$hseq = $aln->get_seq_by_id('subject');
foreach my $feat ($qseq->get_SeqFeatures) {
$org_start = ($feat->get_tag_values('query_start'))[0];
$org_end = ($feat->get_tag_values('query_end'))[0];
# original fragment as represented in the tiled alignment:
$org_fragment = $feat->seq;
}
foreach my $feat ($hseq->get_SeqFeatures) {
$org_start = ($feat->get_tag_values('subject_start'))[0];
$org_end = ($feat->get_tag_values('subject_end'))[0];
# original fragment as represented in the tiled alignment:
$org_fragment = $feat->seq;
}
=head1 DESIGN NOTE
The major calculations are made just-in-time, and then memoized. So,
for example, for a given MapTiling object, a coverage map would
usually be calculated only once (for the query), and at most twice (if
the subject perspective is also desired), and then only when a
statistic is first accessed. Afterward, the map and/or any statistic
is read from storage. So feel free to call the statistic methods
Bio/Seq/EncodedSeq.pm view on Meta::CPAN
@introns = $obj->$dnaseq(-encoding => 'I')
Function: get/set the underlying DNA sequence; will overwrite any
current DNA and/or encoding information present.
Returns : a string of single-letter nucleotide codes, including any
gaps implied by the encoding.
Args : seq - the DNA sequence to be used as a replacement
encoding - the encoding of the DNA sequence (see the new()
constructor); defaults to all 'C' if setting a
new DNA sequence. If no new DNA sequence is
being provided, then the encoding is used as a
"filter" for which to return fragments of
non-overlapping DNA that match the encoding.
location - optional, the location of the DNA sequence to
get/set; defaults to the entire sequence.
=cut
sub dnaseq {
my ($self, @args) = @_;
my ($seq, $enc, $loc) = $self->_rearrange([qw(DNASEQ ENCODING LOCATION)], @args);
return $self;
Bio/SeqIO/agave.pm view on Meta::CPAN
Usage : $self->_process_contig
Function : Parses the data between the <contig></contig> tags.
Args : 2 scalars:
- reference to a scalar holding the line to be parsed.
- scalar holding the attributes for the <contig> tag
to be parsed.
Returns : Data structure holding the values parsed between
the <contig></contig> tags.
Note : Method(s) that call(s) this method : _process_sciobj
Method(s) that this method calls :
_helper_store_attribute_list, _one_tag , _process_fragment_order
=cut
sub _process_contig {
my ($self, $line, $attribute_line) = @_;
my $contig;
$self->_helper_store_attribute_list($attribute_line, \$contig);
$$line = $self->_readline;
# One <db_id>:
$self->_one_tag($line, \$contig, 'db_id');
# Zero or more <fragment_order>
$self->_process_fragment_order($line, \$contig);
return $contig;
}
# ==================================================================================
=head2 _process_fragment_order
Title : _process_fragment_order
Usage : $self->_process_fragment_order
Function : Parses the data between the <fragment_order></fragment_order> tags.
Args : 2 scalars:
- reference to a scalar holding the value of the line to be parsed.
- reference to a data structure to store the <fragment_order> data.
Returns : Nothing.
Note : Method(s) that call(s) this method : _process_contig
Method(s) that this method calls :
_helper_store_attribute_list , _process_fragment_orientation
=cut
sub _process_fragment_order {
my ($self, $line, $data_structure) = @_;
# Because I'm passing a reference to a data structure, I don't need to return it
# after values have been added.
while ($$line =~ /<fragment_order\s?(.*?)\s?>/) {
my $fragment_order;
$self->_helper_store_attribute_list($1, \$fragment_order);
# Store the attribute(s) for <fragment_order> into the
# $fragment_order data structure.
$$line = $self->_readline;
# One or more <fragment_orientation>
$self->_process_fragment_orientation($line, \$fragment_order);
# Don't forget: $line is a reference to a scalar.
push @{$$data_structure->{'fragment_order'}}, $fragment_order;
# Store the data between <fragment_order></fragment_order>
# in $$data_structure.
}
return;
}
# ==================================================================================
=head2 _process_fragment_orientation
Title : _process_fragment_orientation
Usage : $self->_process_fragment_orientation
Function : Parses the data between the <fragment_orientation> and
</fragment_orientation> tags.
Args : 2 scalars:
- reference to a scalar holding the value of the line to be parsed.
- reference to a data structure to store the <fragment_orientation> data.
Returns : Nothing.
Note : Method(s) that call(s) this method : _process_fragment_order
Method(s) that this method calls : _helper_store_attribute_list ,
_process_bio_sequence
=cut
sub _process_fragment_orientation {
my ($self, $line, $data_structure) = @_;
# counter to determine the number of iterations within this while loop.
my $count = 0;
# One or more <fragment_orientation>
while ($$line =~ /<fragment_orientation\s?(.*?)\s?>/) {
my $fragment_orientation;
$self->_helper_store_attribute_list($1, \$fragment_orientation);
$$line = $self->_readline;
# One <bio_sequence>
$$line =~ /<bio_sequence\s?(.*?)\s?>/;
# Process the data between <bio_sequence></bio_sequence>
my $bio_sequence = $self->_process_bio_sequence($line, $1);
$fragment_orientation->{'bio_sequence'} = $bio_sequence;
push @{$$data_structure->{'fragment_orientation'}}, $fragment_orientation;
++$count;
}
$self->throw("Error: Missing <fragment_orientation> tag. Got this: $$line\n\n")
if $count == 0;
return;
}
# ==================================================================================
=head2 _process_bio_sequence
Title : _process_bio_sequence
Usage : $self->_process_bio_sequence
Function : Parses the data between the <bio_sequence></bio_sequence> tags.
Args : 2 scalars:
- reference to a scalar holding the value of the line to be parsed.
- scalar holding the value of the attributes for <bio_sequence>
Returns : data structure holding the values between <bio_sequence></bio_sequence>
Note : Method(s) that call(s) this method : _process_fragment_orientation
Method(s) that this method calls : _helper_store_attribute_list ,
_one_tag , _question_mark_tag , _star_tag , _process_alt_ids ,
_process_xrefs , _process_sequence_map
=cut
sub _process_bio_sequence {
my ($self, $line, $attribute_line) = @_;
Bio/SeqIO/agave.pm view on Meta::CPAN
sub _store_seqs {
my ($self) = @_;
for my $sciobj (@{$self->{'sciobj'}}) {
### $sciobj = $self->{'sciobj'}; # The root node.
for my $contig (@{$sciobj->{'contig'}}) { # Each contig has a fragment order.
for my $fragment_order (@{$contig->{'fragment_order'}}) { # Each fragment order has a fragment_orientation.
for my $fragment_orientation (@{$fragment_order->{'fragment_orientation'}}) {
# Each fragment_orientation contain 1 bio sequence.
my $bio_sequence = $fragment_orientation->{'bio_sequence'}; # <bio_sequence> contains all the
# interesting stuff:
my $sequence = $bio_sequence->{'sequence'};
my $accession_number = $bio_sequence->{'sequence_id'}->[0]; # also use for primary_id
my $organism = $bio_sequence->{'organism'};
my $description = $bio_sequence->{'description'};
my $molecule_type = $bio_sequence->{'molecule_type'}->[0];
my $primary_seq = Bio::PrimarySeq->new(
-id => $accession_number,
Bio/SeqIO/agave.pm view on Meta::CPAN
} # close for my $sequence_map (@{$bio_sequence->{'sequence_map'}}){
} # close if (defined $bio_sequence->{'sequence_map'}){
# This is where the Bio::Seq objects are stored:
push @{$self->{'sequence_objects'}}, $seq;
} # close for my $fragment_orientation
} # close for my $fragment_order
} # close for my $contig
} # close for my $sciobj
# Flag is set so that we know that the sequence objects are now stored in $self.
$self->{'seqs_stored'} = 1;
Bio/SeqIO/agave.pm view on Meta::CPAN
'id', $dblink->primary_id ,
'db_code', $dblink->database );
} else {
$writer ->startTag('db_id',
'id', $seq->display_id ,
'db_code', 'default' );
}
$writer ->endTag('db_id') ;
$writer->startTag('fragment_order');
$writer->startTag('fragment_orientation');
##start bio_sequence
####my $organism = $seq->species->genus . " " . $seq->species->species;
$writer ->startTag('bio_sequence',
'sequence_id', $seq->display_id,
'seq_length', $seq->length,
# 'molecule_type', $seq->moltype, # deprecated
'molecule_type', $self->alphabet,
#'organism_name', $organism
);
Bio/SeqIO/agave.pm view on Meta::CPAN
foreach my $feature ( @{$maps->{ $map_type }} ) {
$self->_write_seqfeature( $feature, $writer ) ;
}
$writer->endTag('annotations');
$writer->endTag('sequence_map');
}
$writer->endTag('bio_sequence');
$writer->endTag('fragment_orientation');
$writer->endTag('fragment_order');
$writer->endTag('contig');
$writer->endTag('sciobj');
}
# ==================================================================================
=head2 _write_seqfeature
Usage : $agave->_write_each_record( $seqfeature, $write )
Function: change seeqfeature data into agave format
Bio/SeqIO/chadoxml.pm view on Meta::CPAN
'feature_property' => 'feature_property',
);
my %feattype_args2so = (
"aberr" => "aberration_junction",
# "conflict" => "sequence_difference",
# "polyA_signal" => "polyA_signal_sequence",
"variation" => "sequence_variant",
"mutation1" => "point_mutation", #for single-base mutation
"mutation2" => "sequence_variant", #for multi-base mutation
"rescue" => "rescue_fragment",
# "rfrag" => "restriction_fragment",
"protein_bind" => "protein_binding_site",
"misc_feature" => "region",
# "prim_transcript" => "primary_transcript",
"CDS" => "polypeptide",
"reg_element" => "regulatory_region",
"seq_variant" => "sequence_variant",
"mat_peptide" => "mature_peptide",
"sig_peptide" => "signal_peptide",
);
Bio/SeqIO/interpro.pm view on Meta::CPAN
sub next_seq {
my $self = shift;
my ($desc);
my $bioSeq = $self->_sequence_factory->create(-verbose =>$self->verbose());
my $zinc = "(\"zincins\")";
my $wing = "\"Winged helix\"";
my $finger = "\"zinc finger\"";
my $xml_fragment = undef;
while(my $line = $self->_readline()){
my $where = index($line, $zinc);
my $wherefinger = index($line, $finger);
my $finishedline = $line;
my $wingwhere = index($line, $wing);
# the interpro XML is not fully formed, so we need to convert the
# extra double quotes and ampersands into appropriate XML character codes
if($where > 0){
Bio/SeqIO/interpro.pm view on Meta::CPAN
}
if(index($line, "&") > 0){
my @linearray = split /&/, $line;
$finishedline = join "&", $linearray[0], $linearray[1];
}
if($wingwhere > 0){
my @linearray = split /$wing/, $line;
$finishedline = join ""Winged helix"", $linearray[0], $linearray[1];
}
$xml_fragment .= $finishedline;
last if $finishedline =~ m!</protein>!;
}
# Match <protein> but not other similar elements like <protein-matches>
return unless $xml_fragment =~ /<protein[\s>]/;
$self->_parse_xml($xml_fragment);
my $dom = $self->_dom;
my ($protein_node) = $dom->findnodes('/protein');
my @interproNodes = $protein_node->findnodes('/protein/interpro');
my @DBNodes = $protein_node->findnodes('/protein/interpro/match');
for(my $interpn=0; $interpn<scalar(@interproNodes); $interpn++){
my $ipnlevel = join "", "/protein/interpro[", $interpn + 1, "]";
my @matchNodes = $protein_node->findnodes($ipnlevel);
for(my $match=0; $match<scalar(@matchNodes); $match++){
Bio/SeqIO/pir.pm view on Meta::CPAN
if ( ! exists $VALID_TYPE{$type} ) {
$self->throw(
"PIR stream read attempted without proper two-letter sequence code [ $type ]"
);
}
} else {
$self->throw("Line does not match PIR format [ $line ]");
}
# P - indicates complete protein
# F - indicates protein fragment
# not sure how to stuff these into a Bio object
# suitable for writing out.
$seq =~ s/\*//g;
$seq =~ s/[\(\)\.\/\=\,]//g;
$seq =~ s/\s+//g; # get rid of whitespace
my ($alphabet) = ('protein');
# TODO - not processing SFS data
return $self->sequence_factory->create(
Bio/SeqUtils.pm view on Meta::CPAN
Bio::SeqUtils->cat(@seqs);
my $catseq=$seqs[0];
# truncate a sequence, retaining features and adjusting their
# coordinates if necessary
my $truncseq = Bio::SeqUtils->trunc_with_features($seq, 100, 200);
# reverse complement a sequence and its features
my $revcomseq = Bio::SeqUtils->revcom_with_features($seq);
# simulate cloning of a fragment into a vector. Cut the vector at
# positions 1000 and 1100 (deleting positions 1001 to 1099) and
# "ligate" a fragment into the sites. The fragment is
# reverse-complemented in this example (option "flip").
# All features of the vector and fragment are preserved and
# features that are affected by the deletion/insertion are
# modified accordingly.
# $vector and $fragment must be Bio::SeqI compliant objects
my $new_molecule = Bio::Sequtils->ligate(
-vector => $vector,
-fragment => $fragment,
-left => 1000,
-right => 1100,
-flip => 1
);
# delete a segment of a sequence (from pos 1000 to 1100, inclusive),
# again preserving features and annotations
my $new_molecule = Bio::SeqUtils->cut( $seq, 1000, 1100 );
# insert a fragment into a recipient between positions 1000 and
# 1001. $recipient is a Bio::SeqI compliant object
my $new_molecule = Bio::SeqUtils::PbrTools->insert(
$recipient_seq,
$fragment_seq,
1000
);
=head1 DESCRIPTION
This class is a holder of methods that work on Bio::PrimarySeqI-
compliant sequence objects, e.g. Bio::PrimarySeq and
Bio::Seq. These methods are not part of the Bio::PrimarySeqI
interface and should in general not be essential to the primary function
of sequence objects. If you are thinking of adding essential
Bio/SeqUtils.pm view on Meta::CPAN
is modified by addition of the remaining sequences. All annotations and
sequence features will be transferred.
The revcom_with_features() and trunc_with_features() methods are similar
to the revcom() and trunc() methods from Bio::Seq, but also adjust any
features associated with the sequence as appropriate.
There are also methods that simulate molecular cloning with rich
sequence objects.
The delete() method cuts a segment out of a sequence and re-joins the
left and right fragments (like splicing or digesting and re-ligating a
molecule). Positions (and types) of sequence features are adjusted
accordingly:
Features that span the deleted segment are converted to split featuress
to indicate the disruption. (Sub)Features that extend into the deleted
segment are truncated.
A new molecule is created and returned.
The insert() method inserts a fragment (which can be a rich Bio::Seq
object) into another sequence object adding all annotations and
features to the final product.
Features that span the insertion site are converted to split features
to indicate the disruption.
A new feature is added to indicate the inserted fragment itself.
A new molecule is created and returned.
The ligate() method simulates digesting a recipient (vector) and
ligating a fragment into it, which can also be flipped if needed. It
is simply a combination of a deletion and an insertion step and
returns a new molecule. The rules for modifying feature locations
outlined above are also used here, e.g. features that span the cut
sites are converted to split features with truncated sub-locations.
=head1 FEEDBACK
=head2 Mailing Lists
Bio/SeqUtils.pm view on Meta::CPAN
)
{
$trunc->add_SeqFeature($_);
}
return $trunc;
}
=head2 delete
Title : delete
Function: cuts a segment out of a sequence and re-joins the left and right fragments
(like splicing or digesting and re-ligating a molecule).
Positions (and types) of sequence features are adjusted accordingly:
Features that span the cut site are converted to split featuress to
indicate the disruption.
Features that extend into the cut-out fragment are truncated.
A new molecule is created and returned.
Usage : my $cutseq = Bio::SeqUtils::PbrTools->cut( $seq, 1000, 1100 );
Args : a Bio::PrimarySeqI compliant object to cut,
first nt of the segment to be deleted
last nt of the segment to be deleted
optional:
hash-ref of options:
clone_obj: if true, clone the input sequence object rather
than calling "new" on the object's class
Bio/SeqUtils.pm view on Meta::CPAN
unless blessed($seq) && $seq->isa('Bio::PrimarySeqI');
$self->throw("Left coordinate ($left) must be >= 1") if $left < 1;
if ( $right > $seq->length ) {
$self->throw( "Right coordinate ($right) must be less than "
. 'sequence length ('
. $seq->length
. ')' );
}
# piece together the sequence string of the remaining fragments
my $left_seq = $seq->subseq( 1, $left - 1 );
my $right_seq = $seq->subseq( $right + 1, $seq->length );
if ( !$left_seq || !$right_seq ) {
$self->throw(
'could not assemble sequences. At least one of the fragments is empty'
);
}
my $seq_str = $left_seq . $right_seq;
# create the new seq object with the same class as the recipient
# or (if requested), make a clone of the existing object. In the
# latter case we need to remove sequence features from the cloned
# object instead of copying them
my $product;
if ( $opts_ref->{clone_obj} ) {
Bio/SeqUtils.pm view on Meta::CPAN
-location_type => 'IN-BETWEEN'
)
);
$product->add_SeqFeature($deletion_feature);
return $product;
}
=head2 insert
Title : insert
Function: inserts a fragment (a Bio::Seq object) into a nother sequence object
adding all annotations and features to the final product.
Features that span the insertion site are converted to split
features to indicate the disruption.
A new feature is added to indicate the inserted fragment itself.
A new molecule is created and returned.
Usage : # insert a fragment after pos 1000
my $insert_seq = Bio::SeqUtils::PbrTools->insert(
$recipient_seq,
$fragment_seq,
1000
);
Args : recipient sequence (a Bio::PrimarySeqI compliant object),
a fragmetn to insert (Bio::PrimarySeqI compliant object),
insertion position (fragment is inserted to the right of this pos)
pos=0 will prepend the fragment to the recipient
optional:
hash-ref of options:
clone_obj: if true, clone the input sequence object rather
than calling "new" on the object's class
Returns : a new Bio::Seq object
=cut
sub insert {
my $self = shift;
my ( $recipient, $fragment, $insert_pos, $opts_ref ) = @_;
$self->throw( 'was expecting 3-4 paramters but got ' . @_ )
unless @_ == 3 || @_ == 4;
$self->throw( 'Recipient object of class ['
. ref($recipient)
. '] should be a Bio::PrimarySeqI ' )
unless blessed($recipient) && $recipient->isa('Bio::PrimarySeqI');
$self->throw( 'Fragment object of class ['
. ref($fragment)
. '] should be a Bio::PrimarySeqI ' )
unless blessed($fragment) && $fragment->isa('Bio::PrimarySeqI');
$self->throw( 'Can\'t concatenate sequences with different alphabets: '
. 'recipient is '
. $recipient->alphabet
. ' and fragment is '
. $fragment->alphabet )
unless $recipient->alphabet eq $fragment->alphabet;
if ( $insert_pos < 0 or $insert_pos > $recipient->length ) {
$self->throw( "insertion position ($insert_pos) must be between 0 and "
. 'recipient sequence length ('
. $recipient->length
. ')' );
}
if ( $fragment->can('is_circular') && $fragment->is_circular ) {
$self->throw('Can\'t insert circular fragments');
}
if ( !$recipient->seq ) {
$self->throw(
'Recipient has no sequence, can not insert into this object');
}
# construct raw sequence of the new molecule
my $left_seq =
$insert_pos > 0
? $recipient->subseq( 1, $insert_pos )
: '';
my $mid_seq = $fragment->seq;
my $right_seq =
$insert_pos < $recipient->length
? $recipient->subseq( $insert_pos + 1, $recipient->length )
: '';
my $seq_str = $left_seq . $mid_seq . $right_seq;
# create the new seq object with the same class as the recipient
# or (if requested), make a clone of the existing object. In the
# latter case we need to remove sequence features from the cloned
# object instead of copying them
my $product;
if ( $opts_ref->{clone_obj} ) {
$product = $self->_new_seq_via_clone( $recipient, $seq_str );
}
else {
my @desc;
push @desc, 'Inserted fragment: ' . $fragment->desc
if defined $fragment->desc;
push @desc, 'Recipient: ' . $recipient->desc
if defined $recipient->desc;
$product = $self->_new_seq_from_old(
$recipient,
{
seq => $seq_str,
display_id => $recipient->display_id,
accession_number => $recipient->accession_number || '',
alphabet => $recipient->alphabet,
desc => join( '; ', @desc ),
verbose => $recipient->verbose || $fragment->verbose,
is_circular => $recipient->is_circular || 0,
}
);
} # if clone_obj
# move annotations from fragment to product
if ( $product->isa("Bio::AnnotatableI")
&& $fragment->isa("Bio::AnnotatableI") )
{
foreach my $key ( $fragment->annotation->get_all_annotation_keys ) {
foreach my $value ( $fragment->annotation->get_Annotations($key) ) {
$product->annotation->add_Annotation( $key, $value );
}
}
}
# move sequence features to product with adjusted coordinates
if ( $product->isa('Bio::SeqI') ) {
# for the fragment, just shift the features to new position
if ( $fragment->isa('Bio::SeqI') ) {
for my $feat ( $fragment->get_SeqFeatures ) {
my $adjfeat = $self->_coord_adjust( $feat, $insert_pos );
$product->add_SeqFeature($adjfeat) if $adjfeat;
}
}
# for recipient, shift and modify features according to insertion.
if ( $recipient->isa('Bio::SeqI') ) {
for my $feat ( $recipient->get_SeqFeatures ) {
my $adjfeat =
$self->_coord_adjust_insertion( $feat, $insert_pos,
$fragment->length );
$product->add_SeqFeature($adjfeat) if $adjfeat;
}
}
}
# add a feature to annotate the insertion
my $insertion_feature = Bio::SeqFeature::Generic->new(
-start => $insert_pos + 1,
-end => $insert_pos + $fragment->length,
-primary_tag => 'misc_feature',
-tag => { note => 'inserted fragment' },
);
$product->add_SeqFeature($insertion_feature);
return $product;
}
=head2 ligate
title : ligate
function: pastes a fragment (which can also have features) into a recipient
sequence between two "cut" sites, preserving features and adjusting
their locations.
This is a shortcut for deleting a segment from a sequence object followed
by an insertion of a fragmnet and is supposed to be used to simulate
in-vitro cloning where a recipient (a vector) is digested and a fragment
is then ligated into the recipient molecule. The fragment can be flipped
(reverse-complemented with all its features).
A new sequence object is returned to represent the product of the reaction.
Features and annotations are transferred from the insert to the product
and features on the recipient are adjusted according to the methods
L</"delete"> amd L</"insert">:
Features spanning the insertion site will be split up into two sub-locations.
(Sub-)features in the deleted region are themselves deleted.
(Sub-)features that extend into the deleted region are truncated.
The class of the product object depends on the class of the recipient (vector)
sequence object. if it is not possible to instantiate a new
object of that class, a Bio::Primaryseq object is created instead.
usage : # insert the flipped fragment between positions 1000 and 1100 of the
# vector, i.e. everything between these two positions is deleted and
# replaced by the fragment
my $new_molecule = Bio::Sequtils::Pbrtools->ligate(
-recipient => $vector,
-fragment => $fragment,
-left => 1000,
-right => 1100,
-flip => 1,
-clone_obj => 1
);
args : recipient: the recipient/vector molecule
fragment: molecule that is to be ligated into the vector
left: left cut site (fragment will be inserted to the right of
this position)
optional:
right: right cut site (fragment will be inseterted to the
left of this position). defaults to left+1
flip: boolean, if true, the fragment is reverse-complemented
(including features) before inserting
clone_obj: if true, clone the recipient object to create the product
instead of calling "new" on its class
returns : a new Bio::Seq object of the ligated fragments
=cut
sub ligate {
my $self = shift;
my ( $recipient, $fragment, $left, $right, $flip, $clone_obj ) =
$self->_rearrange( [qw(RECIPIENT FRAGMENT LEFT RIGHT FLIP CLONE_OBJ )],
@_ );
$self->throw("missing required parameter 'recipient'") unless $recipient;
$self->throw("missing required parameter 'fragment'") unless $fragment;
$self->throw("missing required parameter 'left'") unless defined $left;
$right ||= $left + 1;
$self->throw(
"Fragment must be a Bio::PrimarySeqI compliant object but it is a "
. ref($fragment) )
unless blessed($fragment) && $fragment->isa('Bio::PrimarySeqI');
$fragment = $self->revcom_with_features($fragment) if $flip;
my $opts_ref = {};
$opts_ref->{clone_obj} = 1 if $clone_obj;
# clone in two steps: first delete between the insertion sites,
# then insert the fragment. Step 1 is skipped if insert positions
# are adjacent (no deletion)
my ( $product1, $product2 );
eval {
if ( $right == $left + 1 ) {
$product1 = $recipient;
}
else {
$product1 =
$self->delete( $recipient, $left + 1, $right - 1, $opts_ref );
}
};
$self->throw( "Failed in step 1 (cut recipient): " . $@ ) if $@;
eval { $product2 = $self->insert( $product1, $fragment, $left, $opts_ref ) };
$self->throw( "Failed in step 2 (insert fragment): " . $@ ) if $@;
return $product2;
}
=head2 _coord_adjust_deletion
title : _coord_adjust_deletion
function: recursively adjusts coordinates of seqfeatures on a molecule
where a segment has been deleted.
Bio/SeqUtils.pm view on Meta::CPAN
and a note is added about the size and positin of the insertion.
Features with an IN-BETWEEN location at the insertion site
are lost (such features can only exist between adjacent bases)
usage : my $adjusted_feature = Bio::Sequtils::_coord_adjust_insertion(
$feature,
$insert_pos,
$insert_length
);
args : a Bio::SeqFeatureI compliant object,
insertion position (insert to the right of this position)
length of inserted fragment
returns : a Bio::SeqFeatureI compliant object
=cut
sub _coord_adjust_insertion {
my ( $self, $feat, $insert_pos, $insert_len ) = @_;
$self->throw( 'object [$feat] '
. 'of class ['
. ref($feat)
Bio/Structure/SecStr/DSSP/Res.pm view on Meta::CPAN
=cut
sub getSeq {
my $self = shift;
my $chain = shift;
my ( $pot_chain,
$seq,
$frag_num,
$frag,
$curPdbNum,
$lastPdbNum,
$gap_len,
$i,
$id,
);
my @frags;
if ( !( $chain ) ) {
$chain = ' ';
}
if ( $self->{ 'Seq' }->{ $chain } ) {
return $self->{ 'Seq' }->{ $chain };
}
my $contSegs_pnt = $self->_contSegs();
# load up specified chain
foreach $pot_chain ( @{ $contSegs_pnt } ) {
if ( $pot_chain->[ 2 ] eq $chain ) {
push( @frags, $pot_chain );
}
}
# if that didn't work, just get the first one
if ( !( @frags ) ) {
$chain = $contSegs_pnt->[ 0 ]->[ 2 ];
foreach $pot_chain ( @{ $contSegs_pnt } ) {
if ( $pot_chain->[ 2 ] eq $chain ) {
push( @frags, $pot_chain );
}
}
}
# now build the sequence string
$seq = "";
$frag_num = 0;
foreach $frag ( @frags ) {
$frag_num++;
if ( $frag_num > 1 ) { # we need to put in some gap seq
$curPdbNum = $self->_pdbNum( $frag->[ 0 ] );
$gap_len = $curPdbNum - $lastPdbNum - 1;
if ( $gap_len > 0 ) {
$seq .= 'u' x $gap_len;
}
else {
$seq .= 'u';
}
}
for ( $i = $frag->[ 0 ]; $i <= $frag->[ 1 ]; $i++ ) {
$seq .= $self->_resAA( $i );
}
$lastPdbNum = $self->_pdbNum( $i - 1 );
}
$id = $self->pdbID();
$id .= ":$chain";
Bio/Tools/Gel.pm view on Meta::CPAN
use Bio::PrimarySeq;
use Bio::Restriction::Analysis;
use Bio::Tools::Gel;
# get a sequence
my $d = 'AAAAAAAAAGAATTCTTTTTTTTTTTTTTGAATTCGGGGGGGGGGGGGGGGGGGG';
my $seq1 = Bio::Seq->new(-id=>'groundhog day',-seq=>$d);
# cut it with an enzyme
my $ra=Bio::Restriction::Analysis->new(-seq=>$seq1);
@cuts = $ra->fragments('EcoRI'), 3;
# analyse the fragments in a gel
my $gel = Bio::Tools::Gel->new(-seq=>\@cuts,-dilate=>10);
my %bands = $gel->bands;
foreach my $band (sort {$b <=> $a} keys %bands){
print $band,"\t", sprintf("%.1f", $bands{$band}),"\n";
}
#prints:
#20 27.0
#25 26.0
#10 30.0
t/data/fastq/wrapping_issues.fastq
t/data/fastq/zero_qual.fastq
t/data/fgenesh.out
t/data/footprinter.out
t/data/forward_primer.fa
t/data/forward_reverse_primers.fa
t/data/frac_problems.blast
t/data/frac_problems2.blast
t/data/frac_problems3.blast
t/data/geneid_1.0.out
t/data/genemark-fragment.out
t/data/genemark.out
t/data/genewise.out
t/data/genewise_output.paracel_btk
t/data/genomewise.out
t/data/genomic-seq.epcr
t/data/genomic-seq.fasta
t/data/genomic-seq.genscan
t/data/genomic-seq.mzef
t/data/Genscan.FastA
t/data/gf-s71.needle
t/data/Glimmer2.out
t/data/glimmer3-fragment.detail
t/data/glimmer3-fragment.predict
t/data/Glimmer3.detail
t/data/Glimmer3.predict
t/data/GlimmerHMM.out
t/data/GlimmerM.out
t/data/gmap_f9-multiple_results.txt
t/data/gmap_f9-reverse-strand.txt
t/data/gmap_f9.txt
t/data/GO.defs.test
t/data/GO.defs.test2
t/data/headerless.psl
t/data/testfile.erpin
t/data/testfuzzy.genbank
t/data/tiny.stk
t/data/tmhmm.out
t/data/tmp.fst
t/data/tol-2010-02-18.nhx
t/data/traits.tab
t/data/traittree.nexus
t/data/transfac.dat
t/data/transfac_pro/factor.dat
t/data/transfac_pro/fragment.dat
t/data/transfac_pro/gene.dat
t/data/transfac_pro/matrix.dat
t/data/transfac_pro/readme.txt
t/data/transfac_pro/reference.dat
t/data/transfac_pro/site.dat
t/data/tree_nonewline.nexus
t/data/Treebase-chlamy-dna.nex
t/data/trees.nexml.old.xml
t/data/tricky.wublast
t/data/trna.strict.rnamotif
examples/Bio-DB-GFF/load_ucsc.pl view on Meta::CPAN
use enum qw(:v_ refmethod refsource refgroup refseq refstrand refscore refphase txstart txstop cdsstart cdsstop exonstarts exonstops);
use enum qw(:all_bacends__ x matches misMatches repMatches nCount qNumInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:all_est__ bin matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:all_mrna__ bin matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:all_sts_primer__ matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:all_sts_seq__ matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:bacEndPairs__ bin chrom chromStart chromEnd name score strand pslTable lfCount lfStarts lfSizes lfNames);
use enum qw(:blatFish__ bin matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:gap__ bin chrom chromStart chromEnd ix n size type bridge);
use enum qw(:gl__ bin frag start end strand);
use enum qw(:gold__ bin chrom chromStart chromEnd ix type frag fragStart fragEnd strand);
use enum qw(:intronEst__ bin matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:mrna__ bin matches misMatches repMatches nCount qNumInsert qBaseInsert tNumInsert tBaseInsert strand qName qSize qStart qEnd tName tSize tStart tEnd blockCount blockSizes qStarts tStarts);
use enum qw(:rmsk__ bin swScore milliDiv milliDel milliIns genoName genoStart genoEnd genoLeft strand repName repClass repFamily repStart repEnd repLeft id);
use enum qw(:clonePos__ name seqSize phase chrom chromStart chromEnd stage faFile);
use enum qw(:ctgPos__ contig size chrom chromStart chromEnd);
use enum qw(:cytoBand__ chrom chromStart chromEnd name gieStain);
use enum qw(:fishClones__ chrom chromStart chromEnd name score placeCount bandStarts bandEnds labs placeType accCount accNames stsCount stsNames beCount beNames);
use enum qw(:gcPercent__ chrom chromStart chromEnd name gcPpt);
use enum qw(:genscan__ name chrom strand txStart txEnd cdsStart cdsEnd exonCount exonStarts exonEnds);
use enum qw(:genscanSubopt__ bin chrom chromStart chromEnd name score strand);
examples/db/gb2features.pl view on Meta::CPAN
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag chromosome with values, 11
Feature has tag map with values, 11q13
Feature has tag clone with values, RP11-770G2
Feature has tag organism with values, Homo sapiens
Feature has tag db_xref with values, taxon:9606
Feature from 1 to 31550 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 31651 to 48510 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 48611 to 64044 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 64145 to 78208 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 78309 to 89008 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 89109 to 99704 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 99805 to 107965 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 108066 to 116032 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 116133 to 124010 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 124111 to 130494 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 130595 to 136072 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 136173 to 139649 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 139750 to 144590 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 144691 to 148482 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 148583 to 152279 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 152380 to 153632 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment clone_end:T7
vector_side:left
Feature from 153733 to 155746 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 155847 to 156405 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment clone_end:SP6
vector_side:right
Feature from 156506 to 158398 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 158499 to 161333 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 161434 to 163304 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 163405 to 164604 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 164705 to 166693 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
Feature from 166794 to 168978 Primary tag misc_feature, produced by
EMBL/GenBank/SwissProt
Feature on strand 1
Feature has tag note with values, assembly_fragment
maintenance/big_split/file_classification.csv view on Meta::CPAN
,"t/data/consed_project/phd_dir/ML4924R.phd.1"
,"t/data/consed_project/phd_dir/ML4947F.phd.1"
,"t/data/consed_project/phd_dir/ML4924F.phd.1"
,"t/data/consed_project/phd_dir/ML4922R.phd.1"
,"t/data/factor7.embl"
,"t/data/D10483.gbk"
,"t/data/omim_genemap_test"
,"t/data/Mcjanrna_rdbII.gbk"
,"t/data/no_hsps.blastp"
,"t/data/LOAD_Ccd1.dnd"
,"t/data/glimmer3-fragment.detail"
,"t/data/cysprot.msf"
,"t/data/rpsblast.bls"
,"t/data/AY095303S1.gbk"
,"t/data/spidey.test1"
,"t/data/test.xls"
,"t/data/mpath.ontology.test"
,"t/data/msout_infile2"
,"t/data/test.lasergene"
,"t/data/test.pir"
,"t/data/seg.out"
maintenance/big_split/file_classification.csv view on Meta::CPAN
,"t/data/component.ontology.test"
,"t/data/hmmsearch.out"
,"t/data/P33897"
,"t/data/popgen_saureus.multidat"
,"t/data/sample_dataset.tigr"
,"t/data/test.nhx"
,"t/data/transfac_pro/reference.dat"
,"t/data/transfac_pro/matrix.dat"
,"t/data/transfac_pro/site.dat"
,"t/data/transfac_pro/gene.dat"
,"t/data/transfac_pro/fragment.dat"
,"t/data/transfac_pro/readme.txt"
,"t/data/transfac_pro/factor.dat"
,"t/data/swiss.dat"
,"t/data/psiblast.xml"
,"t/data/ctgdemo.fpc"
,"t/data/test.tab"
,"t/data/test.fasta"
,"t/data/AnnIX-v003.gbk"
,"t/data/headerless.psl"
,"t/data/alleles.fas"
maintenance/big_split/file_classification.csv view on Meta::CPAN
,"t/data/NC_001284.gbk"
,"t/data/dna2.fa"
,"t/data/protpars_longid.phy"
,"t/data/cds_sample.embl"
,"t/data/SPAN_Family4nl.nex"
,"t/data/testdbaccnums.out"
,"t/data/longnames.aln"
,"t/data/tab2part.mif"
,"t/data/gmap_f9-reverse-strand.txt"
,"t/data/test1.wublastp"
,"t/data/genemark-fragment.out"
,"t/data/Q8GBD3.swiss"
,"t/data/stress_test_pubmed.xml"
,"t/data/dnaEbsub_ecoli.wutblastx"
,"t/data/U71225.gb.unix"
,"t/data/test.raw"
,"t/data/codeml315.mlc"
,"t/data/cysprot_vs_gadfly.FASTA"
,"t/data/02_mackerel_dict_cdao_lsid_taxrefs.xml"
,"t/data/hs_owlmonkey.aln"
,"t/data/testdat.exonerate"
maintenance/big_split/file_classification.csv view on Meta::CPAN
,"t/data/blast.report"
,"t/data/multi.blast.m9"
,"t/data/blosum62.bla"
,"t/data/sequencefamily.dat"
,"t/data/noninterleaved.phy"
,"t/data/GO.defs.test2"
,"t/data/signalp.summary"
,"t/data/cysprot1a.msf"
,"t/data/02_dogfish_dict_cdao_lsid_taxrefs.xml"
,"t/data/HUMBETGLOA.gff"
,"t/data/glimmer3-fragment.predict"
,"t/data/version3.scf"
,"t/LocalDB/DBQual.t"
,"t/LocalDB/Registry.t"
,"t/LocalDB/transfac_pro.t"
,"t/LocalDB/Index/Blast.t"
,"t/LocalDB/Index/BlastTable.t"
,"t/LocalDB/Index/Index.t"
,"t/LocalDB/Flat.t"
,"t/LocalDB/BioDBGFF.t"
,"t/LocalDB/SeqFeature.t"