| Summary | Included libraries | Package variables | Synopsis | Description | General documentation | Methods |
| WebCvs |
use Bio::DB::GFF;
# Open the sequence database my $db = Bio::DB::GFF->new( -adaptor => 'dbi::mysqlopt', -dsn => 'dbi:mysql:elegans'); # fetch a 1 megabase segment of sequence starting at landmark "ZK909" my $segment = $db->segment('ZK909', 1 => 1000000); # pull out all transcript features my @transcripts = $segment->features('transcript'); # for each transcript, total the length of the introns my %totals; for my $t (@transcripts) { my @introns = $t->Intron; $totals{$t->name} += $_->length foreach @introns; } # Sort the exons of the first transcript by position my @exons = sort {$a->start <=> $b->start} $transcripts[0]->Exon; # Get a region 1000 bp upstream of first exon my $upstream = $exons[0]->subseq(-1000,0); # get its DNA my $dna = $upstream->seq; # and get all curated polymorphisms inside it @polymorphisms = $upstream->contained_features('polymorphism:curated'); # get all feature types in the database my @types = $db->types; # count all feature types in the segment my %type_counts = $segment->types(-enumerate=>1); # get an iterator on all curated features of type 'exon' or 'intron' my $iterator = $db->get_seq_stream(-type => ['exon:curated','intron:curated']); while (my $s = $iterator->next_seq) { print $s,"\n"; } # find all transcripts annotated as having function 'kinase' my $iterator = $db->get_seq_stream(-type=>'transcript', -attributes=>{Function=>'kinase'}); while (my $s = $iterator->next_seq) { print $s,"\n"; }
- retrieving a segment of sequence based on the ID of a landmarkThe data model used by Bio::DB::GFF is compatible with the GFF flat
- retrieving the DNA from that segment
- finding all annotations that overlap with the segment
- finding all annotations that are completely contained within the
segment
- retrieving all annotations of a particular type, either within a
segment, or globally
- conversion from absolute to relative coordinates and back again,
using any arbitrary landmark for the relative coordinates
- using a sequence segment to create new segments based on relative
offsets
Chr1 curated CDS 365647 365963 . + 1 Transcript "R119.7"The 9 columns are as follows:
Chr1 curated transcript 939627 942410 . + . Transcript Y95B8A.2This object is a predicted transcript named Y95BA.2. In this case,
$segment = $db->segment(-class=>'Transcript',-name=>'Y95B8A.2');It is not necessary for the annotation's method to correspond to the
Chr1 assembly chromosome 1 14972282 . + . Sequence Chr1This indicates that the reference sequence named "Chr1" has length
$segment = $db->segment('Chr1'); # whole chromosome
$segment = $db->segment('Chr1',1=>1000); # first 1000 bp
For your convenience, if, during loading a GFF file, Bio::DB::GFF##sequence-region Chr1 1 14972282It will automatically generate the following entry:
Chr1 reference Component 1 14972282 . + . Sequence Chr1This is sufficient to use Chr1 as a reference point.
##group-tags Accession LocusThis says to use the Accession tag for grouping. If it is not
Chr1 BLASTX similarity 76953 77108 132 + 0 Target Protein:SW:ABL_DROME 493 544The group field contains the Target tag, followed by an identifier for
Chr1 assembly Link 10922906 11177731 . . . Target Sequence:LINK_H06O01 1 254826This indicates that the region between bases 10922906 and 11177731 of
LINK_H06O01 assembly Cosmid 32386 64122 . . . Target Sequence:F49B2 6 31742
Chr1 cur trans 939 942 . + . Transcript Y95B8A.2 ; Gene sma-3 ; Alias sma3This line tags the feature named Transcript Y95B8A.2 as being "Gene"
Adaptor Name DescriptionCheck the Bio/DB/GFF/Adaptor directory and subdirectories for other,
------------ -----------
memory A simple in-memory database suitable for testing and small data sets. berkeleydb An indexed file database based on the DB_File module, suitable for medium-sized read-only data sets. dbi::mysql An interface to a schema implemented in the Mysql relational database management system. dbi::oracle An interface to a schema implemented in the Oracle relational database management system. dbi::pg An interface to a schema implemented in the PostgreSQL relational database management system.
transcript assembles transcripts from features of typeIn addition, this module provides the optional "wormbase_gene"
exon, CDS, 5'UTR, 3'UTR, TSS, and PolyA
clone assembles clones from Clone_left_end, Clone_right_end
and Sequence features.
alignment assembles gapped alignments from features of type
"similarity".
@features = $segment->features('alignment');
will generate an array of aggregated alignment features. However,@features = $segment->features();will return a list of unaggregated similarity segments.
##gff-version 3Unless this version string is present at the top of the GFF file, the
XXXX XXXX gene XXXX XXXX XXXX ID=myGeneThen there will be one group called myGene containing the "gene"
XXXX XXXX mRNA XXXX XXXX XXXX ID=myTranscript;Parent=myGene
XXXX XXXX exon XXXX XXXX XXXX Parent=myTranscript
XXXX XXXX exon XXXX XXXX XXXX Parent=myTranscript
XXXX XXXX gene XXXX XXXX XXXX ID=myGeneThis limitation will be corrected in the next version of Bio::DB::GFF.
XXXX XXXX mRNA XXXX XXXX XXXX ID=myTranscript;Parent=myGene;Alias=myGene
XXXX XXXX exon XXXX XXXX XXXX Parent=myTranscript;Alias=myGene
XXXX XXXX exon XXXX XXXX XXXX Parent=myTranscript;Alias=myGene
| new | Description | Code |
| types | Description | Code |
| classes | Description | Code |
| segment | Description | Code |
| _multiple_return_args | No description | Code |
| abs_segment | No description | Code |
| setup_segment_args | No description | Code |
| features | Description | Code |
| get_seq_stream | Description | Code |
| get_feature_by_name | Description | Code |
| get_feature_by_target | Description | Code |
| get_feature_by_attribute | Description | Code |
| get_feature_by_id | Description | Code |
| get_feature_by_gid | Description | Code |
| delete_fattribute_to_features | Description | Code |
| delete_features | Description | Code |
| delete_groups | Description | Code |
| delete | Description | Code |
| absolute | Description | Code |
| strict_bounds_checking | Description | Code |
| get_Seq_by_id | Description | Code |
| get_Seq_by_accession | Description | Code |
| get_Seq_by_acc | Description | Code |
| get_Stream_by_name | Description | Code |
| get_Stream_by_id | Description | Code |
| get_Stream_by_group | Description | Code |
| all_seqfeatures | Description | Code |
| initialize | Description | Code |
| load_gff | Description | Code |
| load_gff_file | Description | Code |
| load_fasta | Description | Code |
| load_fasta_file | Description | Code |
| load_sequence_string | Description | Code |
| setup_argv | No description | Code |
| lock_on_load | Description | Code |
| meta | Description | Code |
| default_meta_values | Description | Code |
| error | Description | Code |
| debug | Description | Code |
| automerge | Description | Code |
| attributes | Description | Code |
| fast_queries | Description | Code |
| add_aggregator | Description | Code |
| aggregators | Description | Code |
| clear_aggregators | Description | Code |
| preferred_groups | Description | Code |
| _preferred_groups_hash | No description | Code |
| abscoords | Description | Code |
| default_aggregators | Description | Code |
| do_load_gff | Description | Code |
| _load_gff_line | No description | Code |
| _load_sequence_start | No description | Code |
| _load_sequence_finish | No description | Code |
| _load_sequence_line | No description | Code |
| load_sequence | Description | Code |
| insert_sequence_chunk | No description | Code |
| dna_chunk_size | No description | Code |
| insert_sequence | No description | Code |
| default_class | No description | Code |
| refclass | No description | Code |
| setup_load | Description | Code |
| finish_load | Description | Code |
| load_gff_line | Description | Code |
| do_initialize | Description | Code |
| dna | Description | Code |
| features_in_range | No description | Code |
| get_dna | Description | Code |
| get_features | Description | Code |
| _feature_by_name | Description | Code |
| _feature_by_attribute | No description | Code |
| _feature_by_id | Description | Code |
| overlapping_features | Description | Code |
| contained_features | Description | Code |
| contained_in | Description | Code |
| get_abscoords | Description | Code |
| get_types | Description | Code |
| make_feature | Description | Code |
| make_aggregated_feature | No description | Code |
| make_match_sub | Description | Code |
| make_object | Description | Code |
| do_attributes | Description | Code |
| clone | Description | Code |
| _features | Description | Code |
| get_features_iterator | Description | Code |
| split_group | Description | Code |
| _split_gff2_group | Description | Code |
| gff3_name_munging | Description | Code |
| _split_gff3_group | Description | Code |
| _gff3_name_munging | No description | Code |
| _delete_features | Description | Code |
| _delete_groups | No description | Code |
| _delete | No description | Code |
| _delete_fattribute_to_features | No description | Code |
| unescape | No description | Code |
| print_gff3_warning | No description | Code |
| new | code | next | Top |
Title : newThese are the arguments: -adaptor Name of the adaptor module to use. If noneThe adaptor argument must correspond to a module contained within the Bio::DB::GFF::Adaptor namespace. For example, the Bio::DB::GFF::Adaptor::dbi::mysql adaptor is loaded by specifying 'dbi::mysql'. By Perl convention, the adaptors names are lower case because they are loaded at run time. The aggregator array may contain a list of aggregator names, a list of initialized aggregator objects, or a string in the form "aggregator_name{subpart1,subpart2,subpart3/main_method}" (the "/main_method" part is optional, but if present a feature with the main_method must be present in order for aggregation to occur). For example, if you wish to change the components aggregated by the transcript aggregator, you could pass it to the GFF constructor this way: my $transcript =Alternatively, you could create an entirely new transcript aggregator this way: my $new_agg = 'transcript{exon,intron,utr,polyA,spliced_leader}';See Bio::DB::GFF::Aggregator for more details.The -preferred_groups argument is used to change the default processing of the 9th column of GFF version 2 files. By default, the first tag/value pair is used to establish the group class and name. If you pass -preferred_groups a scalar, the parser will look for a tag of the indicated type and use it as the group even if it is not first in the file. If you pass this argument a list of group classes as an array ref, then the list will establish the precedence for searching. The commonly used 'dbi::mysql' adaptor recognizes the following adaptor-specific arguments: Argument DescriptionThe commonly used 'dbi::mysqlopt' adaptor also recogizes the following arguments. Argument Description |
| types | code | prev | next | Top |
Title : typesThis routine returns a list of feature types known to the database. The list can be database-wide or restricted to a region. It is also possible to find out how many times each feature occurs. For range queries, it is usually more convenient to create a Bio::DB::GFF::Segment object, and then invoke it's types() method. Arguments are as follows: -ref ID of reference sequenceThe returned value will be a list of Bio::DB::GFF::Typename objects, which if evaluated in a string context will return the feature type in "method:source" format. This object class also has method() and source() methods for retrieving the like-named fields. If -enumerate is true, then the function returns a hash (not a hash reference) in which the keys are type names in "method:source" format and the values are the number of times each feature appears in the database or segment. The argument -end is a synonum for -stop, and -count is a synonym for -enumerate. |
| classes | code | prev | next | Top |
Title : classesThis routine returns the list of reference classes known to the database, or empty if classes are not used by the database. Classes are distinct from types, being essentially qualifiers on the reference namespaces. |
| segment | code | prev | next | Top |
Title : segmentThis method generates a segment object, which is a Perl object subclassed from Bio::DB::GFF::Segment. The segment can be used to find overlapping features and the raw DNA. When making the segment() call, you specify the ID of a sequence landmark (e.g. an accession number, a clone or contig), and a positional range relative to the landmark. If no range is specified, then the entire extent of the landmark is used to generate the segment. You may also provide the ID of a "reference" sequence, which will set the coordinate system and orientation used for all features contained within the segment. The reference sequence can be changed later. If no reference sequence is provided, then the coordinate system is based on the landmark. Arguments: -name ID of the landmark sequence.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 contig, we can fetch this information like so: my $sourceseq = $segment->sourceseq;and find the start and stop on the source like this: my $start = $segment->abs_start;If we had another segment, say $s2, which is on the same contiguous piece of DNA, we can pass that to the refseq() method in order to establish it as the coordinate reference point: $segment->refseq($s2);Now calling start() will return the start of the segment relative to the beginning of $s2, accounting for differences in strandedness: my $rel_start = $segment->start;IMPORTANT NOTE: This method can be used to return the segment spanned by an arbitrary named annotation. However, if the annotation appears at multiple locations on the genome, for example an EST that maps to multiple locations, then, provided that all locations reside on the same physical segment, the method will return a segment that spans the minimum and maximum positions. If the reference sequence occupies ranges on different physical segments, then it returns them all in an array context, and raises a "multiple segment exception" exception in a scalar context. |
| features | code | prev | next | Top |
Title : featuresThis routine will retrieve features in the database regardless of position. It can be used to return all features, or a subset based on their method and source. Arguments are as follows: -types List of feature types to return. Argument is an arrayIf -iterator is true, then the method returns a single scalar value consisting of a Bio::SeqIO object. You can call next_seq() repeatedly on this object to fetch each of the features in turn. If iterator is false or absent, then all the features are returned as a list. Currently aggregation is disabled when iterating over a series of features. Types are indicated using the nomenclature "method:source". Either of these fields can be omitted, in which case a wildcard is used for the missing field. Type names without the colon (e.g. "exon") are interpreted as the method name and a source wild card. Regular expressions are allowed in either field, as in: "similarity:BLAST.*". The -attributes argument is a hashref containing one or more attributes to match against: -attributes => { Gene => 'abc-1',Attribute matching is simple string matching, and multiple attributesare ANDed together. |
| get_seq_stream | code | prev | next | Top |
Title : get_seq_streamThis routine takes the same arguments as features(), but returns a Bio::SeqIO::Stream-compliant object. Use it like this: $stream = $db->get_seq_stream('exon');NOTE: This is also called get_feature_stream(), since that's what itreally does. |
| get_feature_by_name | code | prev | next | Top |
Title : get_feature_by_nameThis method can be used to fetch a named feature from the database. GFF annotations are named using the group class and name fields, so for features that belong to a group of size one, this method can be used to retrieve that group (and is equivalent to the segment() method). Any Alias attributes are also searched for matching names. An alternative syntax allows you to search for features by name within a circumscribed region: @f = $db->get_feature_by_name(-class => $class,-name=>$name,This method may return zero, one, or several Bio::DB::GFF::Feature objects. Aggregation is performed on features as usual. NOTE: At various times, this function was called fetch_group(), fetch_feature(), fetch_feature_by_name() and segments(). These names are preserved for backward compatibility. |
| get_feature_by_target | code | prev | next | Top |
Title : get_feature_by_targetThis method can be used to fetch a named feature from the database based on its similarity hit. |
| get_feature_by_attribute | code | prev | next | Top |
Title : get_feature_by_attributeThis method can be used to fetch a set of features from the database. Attributes are a list of name=>value pairs. They will be logically ANDED together. |
| get_feature_by_id | code | prev | next | Top |
Title : get_feature_by_idThis method can be used to fetch a feature from the database using its ID. Not all GFF databases support IDs, so be careful with this. |
| get_feature_by_gid | code | prev | next | Top |
Title : get_feature_by_gidThis method can be used to fetch a feature from the database using its group ID. Not all GFF databases support IDs, so be careful with this. The group ID is often more interesting than the feature ID, since groups can be complex objects containing subobjects. |
| delete_fattribute_to_features | code | prev | next | Top |
Title : delete_fattribute_to_featuresPass this method a list of numeric feature ids or a set of features. It will attempt to remove the fattribute_to_features rows of those features from the database and return a count of the rows removed. NOTE: This method is also called delete_fattribute_to_feature(). Also see delete_groups() and delete_features(). |
| delete_features | code | prev | next | Top |
Title : delete_featuresPass this method a list of numeric feature ids or a set of features. It will attempt to remove the features from the database and return a count of the features removed. NOTE: This method is also called delete_feature(). Also see delete_groups(). |
| delete_groups | code | prev | next | Top |
Title : delete_groupsPass this method a list of numeric group ids or a set of features. It will attempt to recursively remove the features and ALL members of their group from the database. It returns a count of the number of features (not groups) returned. NOTE: This method is also called delete_group(). Also see delete_features(). |
| delete | code | prev | next | Top |
Title : deleteThis method deletes all features that overlap the specified region or are of a particular type. If no arguments are provided and the -force argument is true, then deletes ALL features. Arguments: -name ID of the landmark sequence.Examples: $db->delete(-type=>['intron','repeat:repeatMasker']); # remove all introns & repeatsThe short form of this call, as described in segment() is also allowed: $db->delete("chr3",1=>1000);IMPORTANT NOTE: This method only deletes features. It does *NOT*delete the names of groups that contain the deleted features. Group IDs will be reused if you later load a feature with the same group name as one that was previously deleted. NOTE ON FEATURE COUNTS: The DBI-based versions of this call return the result code from the SQL DELETE operation. Some dbd drivers return the count of rows deleted, while others return 0E0. Caveat emptor. |
| absolute | code | prev | next | Top |
Title : absolute$db->absolute(1) will turn on absolute mode for the entire database. All segments retrieved will use absolute coordinates by default, rather than relative coordinates. You can still set them to use relative coordinates by calling $segment->absolute(0). Note that this is not the same as calling abs_segment(); it continues to allow you to look up groups that are not used directly as reference sequences. |
| strict_bounds_checking | code | prev | next | Top |
Title : strict_bounds_checkingThis flag enables extra checks for segment requests that go beyond the ends of their reference sequences. If bounds checking is enabled, then retrieved segments will be truncated to their physical length, and their truncated() methods will return true. If the flag is off (the default), then the module will return segments that appear to extend beyond their physical boundaries. Requests for features beyond the end of the segment will, however, return empty. |
| get_Seq_by_id | code | prev | next | Top |
Title : get_Seq_by_idNOTE: Bio::DB::RandomAccessI compliant method |
| get_Seq_by_accession | code | prev | next | Top |
Title : get_Seq_by_accessionNOTE: Bio::DB::RandomAccessI compliant method |
| get_Seq_by_acc | code | prev | next | Top |
Title : get_Seq_by_accNOTE: Bio::DB::RandomAccessI compliant method |
| get_Stream_by_name | code | prev | next | Top |
Title : get_Stream_by_nameNOTE: This is also called get_Stream_by_batch() |
| get_Stream_by_id | code | prev | next | Top |
Title : get_Stream_by_idNOTE: This is also called get_Stream_by_batch() |
| get_Stream_by_group () | code | prev | next | Top |
| Bioperl compatibility. |
| all_seqfeatures | code | prev | next | Top |
Title : all_seqfeaturesThis is equivalent to calling $db->features() without any types, and will return all the features in the database. The -merge and -iterator arguments are recognized, and behave the same as described for features(). |
| initialize | code | prev | next | Top |
Title : initializeThis method can be used to initialize an empty database. It takes the following named arguments: -erase A boolean value. If true the database will be wiped clean if itOther named arguments may be recognized by subclasses. They become database meta values that control various settable options. As a shortcut (and for backward compatibility) a single true argument is the same as initialize(-erase=>1). |
| load_gff | code | prev | next | Top |
Title : load_gffThis method takes a single overloaded argument, which can be any of: *(1) a scalar corresponding to a GFF file on the systemA pathname to a local GFF file. Any files ending with the .gz, .Z, or .bz2 suffixes will be transparently decompressed with the appropriate command-line utility. *(2) an array reference containing a list of GFF files on the systemFor example ['/home/gff/gff1.gz','/home/gff/gff2.gz'] *(3) directory pathThe indicated directory will be searched for all files ending in the suffixes .gff, .gff.gz, .gff.Z or .gff.bz2. *(4) filehandleAn open filehandle from which to read the GFF data. Tied filehandles now work as well. *(5) a pipe expressionA pipe expression will also work. For example, a GFF file on a remote web server can be loaded with an expression like this: $db->load_gff("lynx -dump -source http://stein.cshl.org/gff_test |");The optional second argument, if true, will turn on verbose statusreports that indicate the progress. If successful, the method will return the number of GFF lines successfully loaded. NOTE:this method used to be called load(), but has been changed. The old method name is also recognized. |
| load_gff_file | code | prev | next | Top |
Title : load_gff_fileThis is provided as an alternative to load_gff_file. It doesn't munge STDIN or play tricks with ARGV. |
| load_fasta | code | prev | next | Top |
Title : load_fastaThis method takes a single overloaded argument, which can be any of: *(1) scalar corresponding to a FASTA file on the systemA pathname to a local FASTA file. Any files ending with the .gz, .Z, or .bz2 suffixes will be transparently decompressed with the appropriate command-line utility. *(2) array reference containing a list of FASTA files on thesystem For example ['/home/fasta/genomic.fa.gz','/home/fasta/genomic.fa.gz'] *(3) path to a directoryThe indicated directory will be searched for all files ending in the suffixes .fa, .fa.gz, .fa.Z or .fa.bz2. *(4) filehandleAn open filehandle from which to read the FASTA data. *(5) pipe expressionA pipe expression will also work. For example, a FASTA file on a remote web server can be loaded with an expression like this: $db->load_gff("lynx -dump -source http://stein.cshl.org/fasta_test.fa |"); |
| load_fasta_file | code | prev | next | Top |
Title : load_fasta_fileThis is provided as an alternative to load_fasta. It doesn't munge STDIN or play tricks with ARGV. |
| load_sequence_string | code | prev | next | Top |
Title : load_sequence_string |
| lock_on_load | code | prev | next | Top |
Title : lock_on_loadThis method is honored by some of the adaptors. If the value is true, the tables used by the GFF modules will be locked for writing during loads and inaccessible to other processes. |
| meta | code | prev | next | Top |
Title : metaGet or set a named metavalues for the database. Metavalues can be used for database-specific settings. By default, this method does nothing! |
| default_meta_values | code | prev | next | Top |
Title : default_meta_valuesThis method returns a list of tag=>value pairs that contain default meta information about the database. It is invoked by initialize() to write out the default meta values. The base class version returns an empty list. For things to work properly, meta value names must be UPPERCASE. |
| error | code | prev | next | Top |
Title : errorThis method can be used to retrieve the last error message. Errors are not reset to empty by successful calls, so contents are only valid immediately after an error condition has been detected. |
| debug | code | prev | next | Top |
Title : debugThis method can be used to turn on debug messages. The exact nature of those messages depends on the adaptor in use. |
| automerge | code | prev | next | Top |
Title : automergeBy default, this module will use the aggregators to merge groups into single composite objects. This default can be changed to false by calling automerge(0). |
| attributes | code | prev | next | Top |
Title : attributesSome GFF version 2 files use the groups column to store a series of attribute/value pairs. In this interpretation of GFF, the first such pair is treated as the primary group for the feature; subsequent pairs are treated as attributes. Two attributes have special meaning: "Note" is for backward compatibility and is used for unstructured text remarks. "Alias" is considered as a synonym for the feature name. If no name is provided, then attributes() returns a flattened hash, of attribute=>value pairs. This lets you do: %attributes = $db->attributes($id);If no arguments are provided, attributes() will return the list of all attribute names: @attribute_names = $db->attributes();Normally, however, attributes() will be called by the feature: @notes = $feature->attributes('Note');In a scalar context, attributes() returns the first value of theattribute if a tag is present, otherwise a hash reference in which the keys are attribute names and the values are anonymous arrays containing the values. |
| fast_queries | code | prev | next | Top |
Title : fast_queriesThe mysql database driver (and possibly others) support a "fast" query mode that caches results on the server side. This makes queries come back faster, particularly when creating iterators. The downside is that while iterating, new queries will die with a "command synch" error. This method turns the feature on and off. For databases that do not support a fast query, this method has no effect. |
| add_aggregator | code | prev | next | Top |
Title : add_aggregatorThis method will append an aggregator to the end of the list of registered aggregators. Three different argument types are accepted: 1) a Bio::DB::GFF::Aggregator object -- will be added |
| aggregators | code | prev | next | Top |
Title : aggregatorsThis method will get or set the list of aggregators assigned to the database. If 1 or more arguments are passed, the existing set will be cleared. |
| clear_aggregators | code | prev | next | Top |
Title : clear_aggregatorsThis method will clear the aggregators stored in the database object. Use aggregators() or add_aggregator() to add some back. |
| preferred_groups | code | prev | next | Top |
Title : preferred_groups |
| abscoords | code | prev | next | Top |
Title : abscoordsThis method is called by Bio::DB::GFF::RelSegment to obtain the absolute coordinates of a sequence landmark. The arguments are the name and class of the landmark. If successful, abscoords() returns the ID of the reference sequence, its class, its start and stop positions, and the orientation of the reference sequence's coordinate system ("+" for forward strand, "-" for reverse strand). If $refseq is present in the argument list, it forces the query to search for the landmark in a particular reference sequence. |
| default_aggregators | code | prev | next | Top |
Title : default_aggregatorsThis method (which is intended to be overridden by adaptors) returns a list of standard aggregators to be applied when no aggregators are specified in the constructor. |
| do_load_gff | code | prev | next | Top |
Title : do_load_gffThis method is called to load a GFF data stream. The method will read GFF features from <> and load them into the database. On exit the method must return the number of features loaded. Note that the method is responsible for parsing the GFF lines. This is to allow for differences in the interpretation of the "group" field, which are legion. You probably want to use load_gff() instead. It is more flexible about the arguments it accepts. |
| load_sequence | code | prev | next | Top |
Title : load_sequenceYou probably want to use load_fasta() instead. |
| setup_load | code | prev | next | Top |
Title : setup_loadThis abstract method gives subclasses a chance to do any schema-specific initialization prior to loading a set of GFF records. It must be implemented by a subclass. |
| finish_load | code | prev | next | Top |
Title : finish_loadThis method gives subclasses a chance to do any schema-specific cleanup after loading a set of GFF records. |
| load_gff_line | code | prev | next | Top |
Title : load_gff_lineThis abstract method is called once per line of the GFF and passed a hashref containing parsed GFF fields. The fields are: {ref => $ref, |
| do_initialize | code | prev | next | Top |
Title : do_initializeThis method implements the initialize() method described above, and takes the same arguments. |
| dna | code | prev | next | Top |
Title : dnaThis method is invoked by Bio::DB::GFF::Segment to fetch the raw DNA sequence. Arguments: -name sequence name -start start position -stop stop position -class sequence class If start and stop are both undef, then the entire DNA is retrieved. So to fetch the whole dna, call like this: $db->dna($name_of_sequence);or like this: $db->dna(-name=>$name_of_sequence,-class=>$class_of_sequence);NOTE: you will probably prefer to create a Segment and then invoke its dna() method. |
| get_dna | code | prev | next | Top |
Title : get_dnaIf start > stop and the sequence is nucleotide, then this method should return the reverse complement. The sequence class may be ignored by those databases that do not recognize different object types. |
| get_features | code | prev | next | Top |
Title : get_featuresThe first argument is a hash reference containing search criteria for retrieving features. It contains the following keys: rangetype One of "overlaps", "contains" or "contained_in". IndicatesThe second argument is a hash reference containing certain options that affect the way information is retrieved: sort_by_groupThe third argument, the $callback, is a code reference to which retrieved features are passed. It is described in more detail below. This routine is responsible for getting arrays of GFF data out of the database and passing them to the callback subroutine. The callback does the work of constructing a Bio::DB::GFF::Feature object out of that data. The callback expects a list of 13 fields: $refseq The reference sequenceThese fields are in the same order as the raw GFF file, with the exception that the group column has been parsed into group class and group name fields. The feature ID, if provided, is a unique identifier of the feature line. The module does not depend on this ID in any way, but it is available via Bio::DB::GFF->id() if wanted. In the dbi::mysql and dbi::mysqlopt adaptor, the ID is a unique row ID. In the acedb adaptor it is not used. |
| _feature_by_name | code | prev | next | Top |
Title : _feature_by_nameThis method is used internally. The callback arguments are the same as those used by make_feature(). This method must be overidden by subclasses. |
| _feature_by_id | code | prev | next | Top |
Title : _feature_by_idThis method is used internally to fetch features either by their ID or their group ID. $ids is a arrayref containing a list of IDs, $type is one of "feature" or "group", and $callback is a callback. The callback arguments are the same as those used by make_feature(). This method must be overidden by subclasses. |
| overlapping_features | code | prev | next | Top |
Title : overlapping_featuresThis method is invoked by Bio::DB::GFF::Segment->features() to find the list of features that overlap a given range. It is generally preferable to create the Segment first, and then fetch the features. This method takes set of named arguments: -refseq ID of the reference sequenceIf -iterator is true, then the method returns a single scalar value consisting of a Bio::SeqIO object. You can call next_seq() repeatedly on this object to fetch each of the features in turn. If iterator is false or absent, then all the features are returned as a list. Currently aggregation is disabled when iterating over a series of features. Types are indicated using the nomenclature "method:source". Either of these fields can be omitted, in which case a wildcard is used for the missing field. Type names without the colon (e.g. "exon") are interpreted as the method name and a source wild card. Regular expressions are allowed in either field, as in: "similarity:BLAST.*". |
| contained_features | code | prev | next | Top |
Title : contained_featuresThis call is similar to overlapping_features(), except that it only retrieves features whose end points are completely contained within the specified range. Generally you will want to fetch a Bio::DB::GFF::Segment object and call its contained_features() method rather than call this directly. |
| contained_in | code | prev | next | Top |
Title : contained_inThis is identical in behavior to features() except that it returns only those features that completely contain the segment. |
| get_abscoords | code | prev | next | Top |
Title : get_abscoordsGiven the name and class of a genomic landmark, this function returns a four-element array consisting of: $absref the ID of the reference sequence that contains this landmarkIf $refseq is provided, the function searches only within the specified reference sequence. |
| get_types | code | prev | next | Top |
Title : get_typesArguments are: $absref the ID of the reference sequenceIf $count is true, then a hash is returned. The keys of the hash are feature type names in the format "method:source" and the values are the number of times a feature of this type overlaps the indicated segment. Otherwise, the call returns a set of Bio::DB::GFF::Typename objects. If $start or $stop are undef, then all features on the indicated segment are enumerated. If $absref is undef, then the call returns all feature types in the database. |
| make_feature | code | prev | next | Top |
Title : make_featureThe $parent argument, if present, is used to establish relative coordinates in the resulting Bio::DB::Feature object. This allows one feature to generate a list of other features that are relative to its coordinate system (for example, finding the coordinates of the second exon relative to the coordinates of the first). The $group_hash allows the group_class/group_name strings to be turned into rich database objects via the make_obect() method (see above). Because these objects may be expensive to create, $group_hash is used to uniquefy them. The index of this hash is the composite key {$group_class,$group_name,$tstart,$tstop}. Values are whatever object is returned by the make_object() method. The remainder of the fields are taken from the GFF line, with the exception that "Target" features, which contain information about the target of a homology search, are parsed into their components. |
| make_match_sub | code | prev | next | Top |
Title : make_match_subThis method is used internally to generate a code subroutine that will accept or reject a feature based on its method and source. It takes an array of parsed type names in the format returned by parse_types(), and generates an anonymous subroutine. The subroutine takes a single Bio::DB::GFF::Feature object and returns true if the feature matches one of the desired feature types, and false otherwise. |
| make_object | code | prev | next | Top |
Title : make_objectThis method is called to make an object from the GFF "group" field. By default, all Target groups are turned into Bio::DB::GFF::Homol objects, and everything else becomes a Bio::DB::GFF::Featname. However, adaptors are free to override this method to generate more interesting objects, such as true BioPerl objects, or Acedb objects. Arguments are: $name database ID for object |
| do_attributes | code | prev | next | Top |
Title : do_attributesThis method is overridden by subclasses in order to return a list of attributes. If called with a tag, returns the value of attributes of that tag type. If called without a tag, returns a flattened array of (tag=>value) pairs. A particular tag can be present multiple times. |
| clone | code | prev | next | Top |
| The clone() method should be used when you want to pass the Bio::DB::GFF object to a child process across a fork(). The child must call clone() before making any queries. The default behavior is to do nothing, but adaptors that use the DBI interface may need to implement this in order to avoid database handle errors. See the dbi adaptor for an example. |
| _features | code | prev | next | Top |
Title : _featuresThis is an internal method that is called by overlapping_features(), contained_features() and features() to create features based on a parent segment's coordinate system. It takes three arguments, a search options hashref, an options hashref, and a parent segment. The search hashref contains the following keys: rangetype One of "overlaps", "contains" or "contained_in". IndicatesThe options hashref contains zero or more of the following keys: sparse turn on optimizations for a rare featureThe $parent argument is a scalar object containing a Bio::DB::GFF::RelSegment object or descendent. |
| get_features_iterator | code | prev | next | Top |
Title : get_features_iteratorThis method takes the same arguments as get_features(), but returns an iterator that can be used to fetch features sequentially, as per Bio::SeqIO. Internally, this method is simply a front end to range_query(). The latter method constructs and executes the query, returning a statement handle. This routine passes the statement handle to the constructor for the iterator, along with the callback. |
| split_group | code | prev | next | Top |
Title : split_groupThis is a method that is called by load_gff_line to parse out the contents of one or more group fields. It returns the class of the group, its name, the start and stop of the target, if any, and an array reference containing any attributes that were stuck into the group field, in [attribute_name,attribute_value] format. |
| _split_gff2_group | code | prev | next | Top |
| This is an internal method called by split_group(). |
| gff3_name_munging | code | prev | next | Top |
Title : gff3_name_mungingIf this is set to true (default false), then features identified in gff3 files with an ID in the format foo:bar will be parsed so that "foo" is the class and "bar" is the name. This is mostly for backward compatibility with GFF2. |
| _split_gff3_group | code | prev | next | Top |
| This is called internally from split_group(). |
| _delete_features(), _delete_groups(),_delete(),_delete_fattribute_to_features() | code | prev | next | Top |
Title : _delete_features(), _delete_groups(),_delete(),_delete_fattribute_to_features()These methods need to be implemented in adaptors. For _delete_features, _delete_groups and _delete_fattribute_to_features, the arguments are a list of feature or group IDs to remove. For _delete(), the argument is a hashref with the three keys 'segments', 'types' and 'force'. The first contains an arrayref of Bio::DB::GFF::RelSegment objects to delete (all FEATURES within the segment are deleted). The second contains an arrayref of [method,source] feature types to delete. The two are ANDed together. If 'force' has a true value, this forces the operation to continue even if it would delete all features. |
| new | description | prev | next | Top |
my $package = shift; my ($adaptor,$aggregators,$args,$refclass,$preferred_groups); if (@_ == 1) { # special case, default to dbi::mysqlopt}
$adaptor = 'dbi::mysqlopt'; $args = {DSN => shift}; } else { ($adaptor,$aggregators,$refclass,$preferred_groups,$args) = rearrange([ [qw(ADAPTOR FACTORY)], [qw(AGGREGATOR AGGREGATORS)], 'REFCLASS', 'PREFERRED_GROUPS' ],@_); } $adaptor ||= 'dbi::mysqlopt'; my $class = "Bio::DB::GFF::Adaptor::\L${adaptor}\E"; unless ($class->can('new')) { eval "require $class;1;" or $package->throw("Unable to load $adaptor adaptor: $@"); } # this hack saves the memory adaptor, which loads the GFF file in new()
$args->{PREFERRED_GROUPS} = $preferred_groups if defined $preferred_groups; my $self = $class->new($args); # handle preferred groups
$self->preferred_groups($preferred_groups) if defined $preferred_groups; $self->default_class($refclass || 'Sequence'); # handle the aggregators.
# aggregators are responsible for creating complex multi-part features
# from the GFF "group" field. If none are provided, then we provide a
# list of the two used in WormBase.
# Each aggregator can be a scalar or a ref. In the former case
# it is treated as a class name to call new() on. In the latter
# the aggreator is treated as a ready made object.
$aggregators = $self->default_aggregators unless defined $aggregators; my @a = ref($aggregators) eq 'ARRAY' ? @$aggregators : $aggregators; for my $a (@a) { $self->add_aggregator($a); } # default settings go here.....
$self->automerge(1); # set automerge to true
$self;
| types | description | prev | next | Top |
my $self = shift; my ($refseq,$start,$stop,$enumerate,$refclass,$types) = rearrange ([ [qw(REF REFSEQ)], qw(START), [qw(STOP END)], [qw(ENUMERATE COUNT)], [qw(CLASS SEQCLASS)], [qw(TYPE TYPES)], ],@_); $types = $self->parse_types($types) if defined $types; $self->get_types($refseq,$refclass,$start,$stop,$enumerate,$types);}
| classes | description | prev | next | Top |
my $self = shift; return ();}
| segment | description | prev | next | Top |
my $self = shift; my @segments = Bio::DB::GFF::RelSegment->new(-factory => $self, $self->setup_segment_args(@_)); foreach (@segments) { $_->absolute(1) if $self->absolute; } $self->_multiple_return_args(@segments);}
| _multiple_return_args | description | prev | next | Top |
my $self = shift; my @args = @_; if (@args == 0) { return; } elsif (@args == 1) { return $args[0]; } elsif (wantarray) { # more than one reference sequence}
return @args; } else { $self->error($args[0]->name, " has more than one reference sequence in database. Please call in a list context to retrieve them all."); $self->throw('multiple segment exception'); return; } } # backward compatibility -- don't use!
# (deliberately undocumented too)
| abs_segment | description | prev | next | Top |
my $self = shift; return $self->segment($self->setup_segment_args(@_),-absolute=>1);}
| setup_segment_args | description | prev | next | Top |
my $self = shift; return @_ if defined $_[0] && $_[0] =~ /^-/; return (-name=>$_[0],-start=>$_[1],-stop=>$_[2]) if @_ == 3; return (-class=>$_[0],-name=>$_[1]) if @_ == 2; return (-name=>$_[0]) if @_ == 1;}
| features | description | prev | next | Top |
my $self = shift; my ($types,$automerge,$sparse,$iterator,$refseq,$start,$end,$other); if (defined $_[0] && $_[0] =~ /^-/) { ($types,$automerge,$sparse,$iterator, $refseq,$start,$end, $other) = rearrange([ [qw(TYPE TYPES)], [qw(MERGE AUTOMERGE)], [qw(RARE SPARSE)], 'ITERATOR', [qw(REFSEQ SEQ_ID)], 'START', [qw(STOP END)], ],@_); } else { $types =\@ _; } # for whole database retrievals, we probably don't want to automerge!}
$automerge = $self->automerge unless defined $automerge; $other ||= {}; $self->_features({ rangetype => $refseq ? 'overlaps' : 'contains', types => $types, refseq => $refseq, start => $start, stop => $end, }, { sparse => $sparse, automerge => $automerge, iterator =>$iterator, %$other, } );
| get_seq_stream | description | prev | next | Top |
my $self = shift; my @args = !defined($_[0]) || $_[0] =~ /^-/ ? (@_,-iterator=>1) : (-types=>\@_,-iterator=>1); $self->features(@args); } *get_feature_stream =\& get_seq_stream;}
| get_feature_by_name | description | prev | next | Top |
my $self = shift; my ($gclass,$gname,$automerge,$ref,$start,$end); if (@_ == 1) { $gclass = $self->default_class; $gname = shift; } else { ($gclass,$gname,$automerge,$ref,$start,$end) = rearrange(['CLASS','NAME','AUTOMERGE', ['REF','REFSEQ'], 'START',['STOP','END'] ],@_); $gclass ||= $self->default_class; } $automerge = $self->automerge unless defined $automerge; # we need to refactor this... It's repeated code (see below)...}
my @aggregators; if ($automerge) { for my $a ($self->aggregators) { push @aggregators,$a if $a->disaggregate([],$self); } } my %groups; # cache the groups we create to avoid consuming too much unecessary memory
my $features = []; my $callback = sub { push @$features,$self->make_feature(undef,\%groups,@_) }; my $location = [$ref,$start,$end] if defined $ref; $self->_feature_by_name($gclass,$gname,$location,$callback); warn "aggregating...\n" if $self->debug; foreach my $a (@aggregators) { # last aggregator gets first shot
$a->aggregate($features,$self) or next; } @$features; } # horrible indecision regarding proper names!
*fetch_group = *fetch_feature = *fetch_feature_by_name =\& get_feature_by_name; *segments =\& segment;
| get_feature_by_target | description | prev | next | Top |
shift->get_feature_by_name(@_);}
| get_feature_by_attribute | description | prev | next | Top |
my $self = shift; my %attributes = ref($_[0]) ? %{$_[0]} : @_; # we need to refactor this... It's repeated code (see above)...}
my @aggregators; if ($self->automerge) { for my $a ($self->aggregators) { unshift @aggregators,$a if $a->disaggregate([],$self); } } my %groups; # cache the groups we create to avoid consuming too much unecessary memory
my $features = []; my $callback = sub { push @$features,$self->make_feature(undef,\%groups,@_) }; $self->_feature_by_attribute(\%attributes,$callback); warn "aggregating...\n" if $self->debug; foreach my $a (@aggregators) { # last aggregator gets first shot
$a->aggregate($features,$self) or next; } @$features; } # more indecision...
*fetch_feature_by_attribute =\& get_feature_by_attribute;
| get_feature_by_id | description | prev | next | Top |
my $self = shift; my $id = ref($_[0]) eq 'ARRAY' ? $_[0] :\@ _; my %groups; # cache the groups we create to avoid consuming too much unecessary memory}
my $features = []; my $callback = sub { push @$features,$self->make_feature(undef,\%groups,@_) }; $self->_feature_by_id($id,'feature',$callback); return wantarray ? @$features : $features->[0]; } *fetch_feature_by_id =\& get_feature_by_id;
| get_feature_by_gid | description | prev | next | Top |
my $self = shift; my $id = ref($_[0]) eq 'ARRAY' ? $_[0] :\@ _; my %groups; # cache the groups we create to avoid consuming too much unecessary memory}
my $features = []; my $callback = sub { push @$features,$self->make_feature(undef,\%groups,@_) }; $self->_feature_by_id($id,'group',$callback); return wantarray ? @$features : $features->[0]; } *fetch_feature_by_gid =\& get_feature_by_gid;
| delete_fattribute_to_features | description | prev | next | Top |
my $self = shift; my @features_or_ids = @_; my @ids = map {UNIVERSAL::isa($_,'Bio::DB::GFF::Feature') ? $_->id : $_} @features_or_ids; return unless @ids; $self->_delete_fattribute_to_features(@ids);}
| delete_features | description | prev | next | Top |
my $self = shift; my @features_or_ids = @_; my @ids = map {UNIVERSAL::isa($_,'Bio::DB::GFF::Feature') ? $_->id : $_} @features_or_ids; return unless @ids; $self->_delete_features(@ids);}
| delete_groups | description | prev | next | Top |
my $self = shift; my @features_or_ids = @_; my @ids = map {UNIVERSAL::isa($_,'Bio::DB::GFF::Feature') ? $_->group_id : $_} @features_or_ids; return unless @ids; $self->_delete_groups(@ids);}
| delete | description | prev | next | Top |
my $self = shift; my @args = $self->setup_segment_args(@_); my ($name,$class,$start,$end,$offset,$length,$type,$force,$range_type) = rearrange([['NAME','REF'],'CLASS','START',[qw(END STOP)],'OFFSET', 'LENGTH',[qw(TYPE TYPES)],'FORCE','RANGE_TYPE'],@args); $offset = 0 unless defined $offset; $start = $offset+1 unless defined $start; $end = $start+$length-1 if !defined $end and $length; $class ||= $self->default_class; my $types = $self->parse_types($type); # parse out list of types}
$range_type ||= 'overlaps'; $self->throw("range type must be one of {". join(',',keys %valid_range_types). "}\n") unless $valid_range_types{lc $range_type}; my @segments; if (defined $name && $name ne '') { my @args = (-name=>$name,-class=>$class); push @args,(-start=>$start) if defined $start; push @args,(-end =>$end) if defined $end; @segments = $self->segment(@args); return unless @segments; } $self->_delete({segments =>\@ segments, types => $types, range_type => $range_type, force => $force} );
| absolute | description | prev | next | Top |
my $self = shift; my $d = $self->{absolute}; $self->{absolute} = shift if @_; $d;}
| strict_bounds_checking | description | prev | next | Top |
my $self = shift; my $d = $self->{strict}; $self->{strict} = shift if @_; $d;}
| get_Seq_by_id | description | prev | next | Top |
my $self = shift; $self->get_feature_by_name(@_);}
| get_Seq_by_accession | description | prev | next | Top |
my $self = shift; $self->get_feature_by_name(@_);}
| get_Seq_by_acc | description | prev | next | Top |
my $self = shift; $self->get_feature_by_name(@_);}
| get_Stream_by_name | description | prev | next | Top |
my $self = shift; my @ids = @_; my $id = ref($ids[0]) ? $ids[0] :\@ ids; Bio::DB::GFF::ID_Iterator->new($self,$id,'name');}
| get_Stream_by_id | description | prev | next | Top |
my $self = shift; my @ids = @_; my $id = ref($ids[0]) ? $ids[0] :\@ ids; Bio::DB::GFF::ID_Iterator->new($self,$id,'feature');}
| get_Stream_by_group | description | prev | next | Top |
my $self = shift; my @ids = @_; my $id = ref($ids[0]) ? $ids[0] :\@ ids; Bio::DB::GFF::ID_Iterator->new($self,$id,'group');}
| all_seqfeatures | description | prev | next | Top |
my $self = shift; my ($automerge,$iterator)= rearrange([ [qw(MERGE AUTOMERGE)], 'ITERATOR' ],@_); my @args; push @args,(-merge=>$automerge) if defined $automerge; push @args,(-iterator=>$iterator) if defined $iterator; $self->features(@args);}
| initialize | description | prev | next | Top |
my $self = shift; my ($erase,$meta) = rearrange(['ERASE'],@_); $meta ||= {}; # initialize (possibly erasing)}
return unless $self->do_initialize($erase); my @default = $self->default_meta_values; # this is an awkward way of uppercasing the
# even-numbered values (necessary for case-insensitive SQL databases)
for (my $i=0; $i<@default; $i++) { $default[$i] = uc $default[$i] if !($i % 2); } my %values = (@default,%$meta); foreach (keys %values) { $self->meta($_ => $values{$_}); } 1;
| load_gff | description | prev | next | Top |
my $self = shift; my $file_or_directory = shift || '.'; my $verbose = shift; local $self->{__verbose__} = $verbose; return $self->do_load_gff($file_or_directory) if ref($file_or_directory) && tied *$file_or_directory; my $tied_stdin = tied(*STDIN); open my $SAVEIN,"<&STDIN" unless $tied_stdin; local @ARGV = $self->setup_argv($file_or_directory,'gff','gff3') or return; # to play tricks with reader}
my $result = $self->do_load_gff('ARGV'); open STDIN,"<", $SAVEIN unless $tied_stdin; # restore STDIN
return $result; } *load =\& load_gff;
| load_gff_file | description | prev | next | Top |
my $self = shift; my $file = shift; my $verbose = shift; my $fh = IO::File->new($file) or return; return $self->do_load_gff($fh);}
| load_fasta | description | prev | next | Top |
my $self = shift; my $file_or_directory = shift || '.'; my $verbose = shift; local $self->{__verbose__} = $verbose; return $self->load_sequence($file_or_directory) if ref($file_or_directory) && tied *$file_or_directory; my $tied = tied(*STDIN); open my $SAVEIN, "<&STDIN" unless $tied; local @ARGV = $self->setup_argv($file_or_directory,'fa','dna','fasta') or return; # to play tricks with reader}
my $result = $self->load_sequence('ARGV'); open STDIN,"<", $SAVEIN unless $tied; # restore STDIN
return $result;
| load_fasta_file | description | prev | next | Top |
my $self = shift; my $file = shift; my $verbose = shift; my $fh = IO::File->new($file) or return; return $self->do_load_fasta($fh);}
| load_sequence_string | description | prev | next | Top |
my $self = shift; my ($acc,$seq) = @_; my $offset = 0; $self->insert_sequence_chunk($acc,\$offset,\$seq) or return; $self->insert_sequence($acc,$offset,$seq) or return; 1;}
| setup_argv | description | prev | next | Top |
my $self = shift; my $file_or_directory = shift; my @suffixes = @_; no strict 'refs'; # so that we can call fileno() on the argument}
my @argv; if (-d $file_or_directory) { # Because glob() is broken with long file names that contain spaces
$file_or_directory = Win32::GetShortPathName($file_or_directory) if $^O =~ /^MSWin/i && eval 'use Win32; 1'; @argv = map { glob("$file_or_directory/*.{$_,$_.gz,$_.Z,$_.bz2}")} @suffixes; }elsif (my $fd = fileno($file_or_directory)) { open STDIN,"<&=$fd" or $self->throw("Can't dup STDIN"); @argv = '-'; } elsif (ref $file_or_directory) { @argv = @$file_or_directory; } else { @argv = $file_or_directory; } foreach (@argv) { if (/\.gz$/) { $_ = "gunzip -c $_ |"; } elsif (/\.Z$/) { $_ = "uncompress -c $_ |"; } elsif (/\.bz2$/) { $_ = "bunzip2 -c $_ |"; } } @argv;
| lock_on_load | description | prev | next | Top |
my $self = shift; my $d = $self->{lock}; $self->{lock} = shift if @_; $d;}
| meta | description | prev | next | Top |
my $self = shift; my ($name,$value) = @_; return;}
| default_meta_values | description | prev | next | Top |
my $self = shift; return ();}
| error | description | prev | next | Top |
my $self = shift; my $g = $self->{error}; $self->{error} = join '',@_ if @_; $g;}
| debug | description | prev | next | Top |
my $self = shift; my $g = $self->{debug}; $self->{debug} = shift if @_; $g;}
| automerge | description | prev | next | Top |
my $self = shift; my $g = $self->{automerge}; $self->{automerge} = shift if @_; $g;}
| attributes | description | prev | next | Top |
my $self = shift; my ($id,$tag) = @_; my @result = $self->do_attributes(@_) or return; return @result if wantarray; # what to do in an array context}
return $result[0] if $tag; my %result; while (my($key,$value) = splice(@result,0,2)) { push @{$result{$key}},$value; } return\% result;
| fast_queries | description | prev | next | Top |
my $self = shift; my $d = $self->{fast_queries}; $self->{fast_queries} = shift if @_; $d;}
| add_aggregator | description | prev | next | Top |
my $self = shift; my $aggregator = shift; my $list = $self->{aggregators} ||= []; if (ref $aggregator) { # an object}
@$list = grep {$_->get_method ne $aggregator->get_method} @$list; push @$list,$aggregator; } elsif ($aggregator =~ /^(\w+)\{([^\/\}]+)\/?(.*)\}$/) { my($agg_name,$subparts,$mainpart) = ($1,$2,$3); my @subparts = split /,\s*/,$subparts; my @args = (-method => $agg_name, -sub_parts =>\@ subparts); if ($mainpart) { push @args,(-main_method => $mainpart, -whole_object => 1); } warn "making an aggregator with (@args), subparts = @subparts" if $self->debug; push @$list,Bio::DB::GFF::Aggregator->new(@args); } else { my $class = "Bio::DB::GFF::Aggregator::\L${aggregator}\E"; eval "require $class; 1" or $self->throw("Unable to load $aggregator aggregator: $@"); push @$list,$class->new(); }
| aggregators | description | prev | next | Top |
my $self = shift; my $d = $self->{aggregators}; if (@_) { $self->clear_aggregators; $self->add_aggregator($_) foreach @_; } return unless $d; return @$d;}
| clear_aggregators | description | prev | next | Top |
shift->{aggregators} = []}
| preferred_groups | description | prev | next | Top |
my $self = shift; my $d = $self->{preferred_groups}; if (@_) { my @v = map {ref($_) eq 'ARRAY' ? @$_ : $_} @_; $self->{preferred_groups} =\@ v; delete $self->{preferred_groups_hash}; } return unless $d; return @$d;}
| _preferred_groups_hash | description | prev | next | Top |
my $self = shift; my $gff3 = shift; return $self->{preferred_groups_hash} if exists $self->{preferred_groups_hash}; my $count = 0; my @preferred = $self->preferred_groups; # defaults}
if (!@preferred) { @preferred = $gff3 || $self->{load_data}{gff3_flag} ? qw(Target Parent ID) : qw(Target Sequence Transcript); } my %preferred = map {lc($_) => @preferred-$count++} @preferred; return $self->{preferred_groups_hash} =\% preferred;
| abscoords | description | prev | next | Top |
my $self = shift; my ($name,$class,$refseq) = @_; $class ||= $self->{default_class}; $self->get_abscoords($name,$class,$refseq);}
| default_aggregators | description | prev | next | Top |
my $self = shift; return ['processed_transcript','alignment'];}
| do_load_gff | description | prev | next | Top |
my $self = shift; my $io_handle = shift; local $self->{load_data} = { lineend => (-t STDERR && !$ENV{EMACS} ? "\r" : "\n"), count => 0 }; $self->setup_load(); my $mode = 'gff'; while (<$io_handle>) { chomp; if ($mode eq 'gff') { if (/^>/) { # Sequence coming}
$mode = 'fasta'; $self->_load_sequence_start; $self->_load_sequence_line($_); } else { $self->_load_gff_line($_); } } elsif ($mode eq 'fasta') { if (/^##|\t/) { # Back to GFF mode
$self->_load_sequence_finish; $mode = 'gff'; $self->_load_gff_line($_); } else { $self->_load_sequence_line($_); } } } $self->finish_load(); $self->_load_sequence_finish; return $self->{load_data}{count};
| _load_gff_line | description | prev | next | Top |
my $self = shift; my $line = shift; my $lineend = $self->{load_data}{lineend}; $self->{load_data}{gff3_flag}++ if $line =~ /^\#\#\s*gff-version\s+3/; if (defined $self->{load_data}{gff3_flag} and !defined $self->{load_data}{gff3_warning}) { $self->print_gff3_warning(); $self->{load_data}{gff3_warning}=1; } $self->preferred_groups(split(/\s+/,$1)) if $line =~ /^\#\#\s*group-tags?\s+(.+)/; if ($line =~ /^\#\#\s*sequence-region\s+(\S+)\s+(-?\d+)\s+(-?\d+)/i) { # header line}
$self->load_gff_line( { ref => $1, class => 'Sequence', source => 'reference', method => 'Component', start => $2, stop => $3, score => undef, strand => undef, phase => undef, gclass => 'Sequence', gname => $1, tstart => undef, tstop => undef, attributes => [], } ); return $self->{load_data}{count}++; } return if /^#/; my ($ref,$source,$method,$start,$stop,$score,$strand,$phase,$group) = split "\t",$line; return unless defined($ref) && defined($method) && defined($start) && defined($stop); foreach (\$score,\$strand,\$phase) { undef $$_ if $$_ eq '.'; } my ($gclass,$gname,$tstart,$tstop,$attributes) = $self->split_group($group,$self->{load_data}{gff3_flag}); # no standard way in the GFF file to denote the class of the reference sequence -- drat!
# so we invoke the factory to do it
my $class = $self->refclass($ref); # call subclass to do the dirty work
if ($start > $stop) { ($start,$stop) = ($stop,$start); if ($strand eq '+') { $strand = '-'; } elsif ($strand eq '-') { $strand = '+'; } } # GFF2/3 transition stuff
$gclass = [$gclass] unless ref $gclass; $gname = [$gname] unless ref $gname; for (my $i=0; $i<@$gname;$i++) { $self->load_gff_line({ref => $ref, class => $class, source => $source, method => $method, start => $start, stop => $stop, score => $score, strand => $strand, phase => $phase, gclass => $gclass->[$i], gname => $gname->[$i], tstart => $tstart, tstop => $tstop, attributes => $attributes} ); $self->{load_data}{count}++; }
| _load_sequence_start | description | prev | next | Top |
my $self = shift; my $ld = $self->{load_data}; undef $ld->{id}; $ld->{offset} = 0; $ld->{seq} = '';}
| _load_sequence_finish | description | prev | next | Top |
my $self = shift; my $ld = $self->{load_data}; $self->insert_sequence($ld->{id},$ld->{offset},$ld->{seq}) if defined $ld->{id};}
| _load_sequence_line | description | prev | next | Top |
my $self = shift; my $line = shift; my $ld = $self->{load_data}; my $lineend = $ld->{lineend}; if (/^>(\S+)/) { $self->insert_sequence($ld->{id},$ld->{offset},$ld->{seq}) if defined $ld->{id}; $ld->{id} = $1; $ld->{offset} = 0; $ld->{seq} = ''; $ld->{count}++; print STDERR $ld->{count}," sequences loaded$lineend" if $self->{__verbose__} && $ld->{count} % 1000 == 0; } else { $ld->{seq} .= $_; $self->insert_sequence_chunk($ld->{id},\$ld->{offset},\$ld->{seq}); }}
| load_sequence | description | prev | next | Top |
my $self = shift; my $io_handle = shift; local $self->{load_data} = { lineend => (-t STDERR && !$ENV{EMACS} ? "\r" : "\n"), count => 0 }; $self->_load_sequence_start; while (<$io_handle>) { chomp; $self->_load_sequence_line($_); } $self->_load_sequence_finish; return $self->{load_data}{count};}
| insert_sequence_chunk | description | prev | next | Top |
my $self = shift; my ($id,$offsetp,$seqp) = @_; if (my $cs = $self->dna_chunk_size) { while (length($$seqp) >= $cs) { my $chunk = substr($$seqp,0,$cs); $self->insert_sequence($id,$$offsetp,$chunk); $$offsetp += length($chunk); substr($$seqp,0,$cs) = ''; } } return 1; # the calling routine may expect success or failure}
} # used to store big pieces of DNA in itty bitty pieces
| dna_chunk_size | description | prev | next | Top |
return 0;}| insert_sequence | description | prev | next | Top |
my $self = shift; my($id,$offset,$seq) = @_; $self->throw('insert_sequence(): must be defined in subclass'); } # This is the default class for reference points. Defaults to Sequence.}
| default_class | description | prev | next | Top |
my $self = shift; return 'Sequence' unless ref $self; my $d = $self->{default_class}; $self->{default_class} = shift if @_; $d; } # gets name of the reference sequence, and returns its class}
# currently just calls default_class
| refclass | description | prev | next | Top |
my $self = shift; my $name = shift; return $self->default_class;}
| setup_load | description | prev | next | Top |
# default, do nothing}
| finish_load | description | prev | next | Top |
# default, do nothing}
| load_gff_line | description | prev | next | Top |
shift->throw("load_gff_line(): must be implemented by an adaptor");}
| do_initialize | description | prev | next | Top |
shift->throw('do_initialize(): must be implemented by an adaptor');}
| dna | description | prev | next | Top |
my $self = shift; my ($id,$start,$stop,$class) = rearrange([ [qw(NAME ID REF REFSEQ)], qw(START), [qw(STOP END)], 'CLASS', ],@_); # return unless defined $start && defined $stop;}
$self->get_dna($id,$start,$stop,$class);
| features_in_range | description | prev | next | Top |
my $self = shift; my ($range_type,$refseq,$class,$start,$stop,$types,$parent,$sparse,$automerge,$iterator,$other) = rearrange([ [qw(RANGE_TYPE)], [qw(REF REFSEQ)], qw(CLASS), qw(START), [qw(STOP END)], [qw(TYPE TYPES)], qw(PARENT), [qw(RARE SPARSE)], [qw(MERGE AUTOMERGE)], 'ITERATOR' ],@_); $other ||= {}; # $automerge = $types && $self->automerge unless defined $automerge;}
$automerge = $self->automerge unless defined $automerge; $self->throw("range type must be one of {". join(',',keys %valid_range_types). "}\n") unless $valid_range_types{lc $range_type}; $self->_features({ rangetype => lc $range_type, refseq => $refseq, refclass => $class, start => $start, stop => $stop, types => $types }, { sparse => $sparse, automerge => $automerge, iterator => $iterator, %$other, }, $parent);
| get_dna | description | prev | next | Top |
my $self = shift; my ($id,$start,$stop,$class,) = @_; $self->throw("get_dna() must be implemented by an adaptor");}
| get_features | description | prev | next | Top |
my $self = shift; my ($search,$options,$callback) = @_; $self->throw("get_features() must be implemented by an adaptor");}
| _feature_by_name | description | prev | next | Top |
my $self = shift; my ($class,$name,$location,$callback) = @_; $self->throw("_feature_by_name() must be implemented by an adaptor");}
| _feature_by_attribute | description | prev | next | Top |
my $self = shift; my ($attributes,$callback) = @_; $self->throw("_feature_by_name() must be implemented by an adaptor");}
| _feature_by_id | description | prev | next | Top |
my $self = shift; my ($ids,$type,$callback) = @_; $self->throw("_feature_by_id() must be implemented by an adaptor");}
| overlapping_features | description | prev | next | Top |
my $self = shift; $self->features_in_range(-range_type=>'overlaps',@_);}
| contained_features | description | prev | next | Top |
my $self = shift; $self->features_in_range(-range_type=>'contains',@_);}
| contained_in | description | prev | next | Top |
my $self = shift; $self->features_in_range(-range_type=>'contained_in',@_);}
| get_abscoords | description | prev | next | Top |
my $self = shift; my ($name,$class,$refseq) = @_; $self->throw("get_abscoords() must be implemented by an adaptor");}
| get_types | description | prev | next | Top |
my $self = shift; my ($refseq,$class,$start,$stop,$count,$types) = @_; $self->throw("get_types() must be implemented by an adaptor");}
| make_feature | description | prev | next | Top |
my $self = shift; my ($parent,$group_hash, # these arguments provided by generic mechanisms}
$srcseq, # the rest is provided by adaptor
$start,$stop, $source,$method, $score,$strand,$phase, $group_class,$group_name, $tstart,$tstop, $db_id,$group_id) = @_; return unless $srcseq; # return undef if called with no arguments. This behavior is used for
# on-the-fly aggregation.
my $group; # undefined
if (defined $group_class && defined $group_name) { $tstart ||= ''; $tstop ||= ''; if ($group_hash) { $group = $group_hash->{$group_class,$group_name,$tstart,$tstop} ||= $self->make_object($group_class,$group_name,$tstart,$tstop); } else { $group = $self->make_object($group_class,$group_name,$tstart,$tstop); } } # fix for some broken GFF files
# unfortunately - has undesired side effects
# if (defined $tstart && defined $tstop && !defined $strand) {
# $strand = $tstart <= $tstop ? '+' : '-';
# }
if (ref $parent) { # note that the src sequence is ignored
return Bio::DB::GFF::Feature->new_from_parent($parent,$start,$stop, $method,$source, $score,$strand,$phase, $group,$db_id,$group_id, $tstart,$tstop); } else { return Bio::DB::GFF::Feature->new($self,$srcseq, $start,$stop, $method,$source, $score,$strand,$phase, $group,$db_id,$group_id, $tstart,$tstop); }
| make_aggregated_feature | description | prev | next | Top |
my $self = shift; my ($accumulated_features,$parent,$aggregators) = splice(@_,0,3); my $feature = $self->make_feature($parent,undef,@_); return [$feature] if $feature && !$feature->group; # if we have accumulated features and either:}
# (1) make_feature() returned undef, indicated very end or
# (2) the current group is different from the previous one
local $^W = 0; # irritating uninitialized value warning in next statement
if (@$accumulated_features && (!defined($feature) || ($accumulated_features->[-1]->group ne $feature->group))) { foreach my $a (@$aggregators) { # last aggregator gets first shot
$a->aggregate($accumulated_features,$self) or next; } my @result = @$accumulated_features; @$accumulated_features = $feature ? ($feature) : (); return unless @result; return\@ result ; } push @$accumulated_features,$feature; return;
| make_match_sub | description | prev | next | Top |
my $self = shift; my $types = shift; return sub { 1 } unless ref $types && @$types; my @expr; for my $type (@$types) { my ($method,$source) = @$type; $method = $method ? "\\Q$method\\E" : ".*"; $source = $source ? ":\\Q$source\\E" : "(?::.+)?"; push @expr,"${method}${source}"; } my $expr = join '|',@expr; return $self->{match_subs}{$expr} if $self->{match_subs}{$expr}; my $sub =<<END; sub { my\$ feature = shift or return; return\$ feature->type =~ /^($expr)\$/i; } END warn "match sub: $sub\n" if $self->debug; undef $@; my $compiled_sub = eval $sub; $self->throw($@) if $@; return $self->{match_subs}{$expr} = $compiled_sub;}
| make_object | description | prev | next | Top |
my $self = shift; my ($class,$name,$start,$stop) = @_; return Bio::DB::GFF::Homol->new($self,$class,$name,$start,$stop) if defined $start and length $start; return Bio::DB::GFF::Featname->new($class,$name);}
| do_attributes | description | prev | next | Top |
my $self = shift; my ($id,$tag) = @_; return ();}
| clone | description | prev | next | Top |
| _features | description | prev | next | Top |
my $self = shift; my ($search,$options,$parent) = @_; (@{$search}{qw(start stop)}) = (@{$search}{qw(stop start)}) if defined($search->{start}) && $search->{start} > $search->{stop}; $search->{refseq} = $search->{seq_id} if exists $search->{seq_id}; my $types = $self->parse_types($search->{types}); # parse out list of types}
my @aggregated_types = @$types; # keep a copy
# allow the aggregators to operate on the original
my @aggregators; if ($options->{automerge}) { for my $a ($self->aggregators) { $a = $a->clone if $options->{iterator}; unshift @aggregators,$a if $a->disaggregate(\@aggregated_types,$self); } } if ($options->{iterator}) { my @accumulated_features; my $callback = $options->{automerge} ? sub { $self->make_aggregated_feature(\@accumulated_features,$parent,\@aggregators,@_) } : sub { [$self->make_feature($parent,undef,@_)] }; return $self->get_features_iterator({ %$search, types =>\@ aggregated_types }, { %$options, sort_by_group => $options->{automerge} }, $callback ); } my %groups; # cache the groups we create to avoid consuming too much unecessary memory
my $features = []; my $callback = sub { push @$features,$self->make_feature($parent,\%groups,@_) }; $self->get_features({ %$search, types =>\@ aggregated_types }, $options, $callback); if ($options->{automerge}) { warn "aggregating...\n" if $self->debug; foreach my $a (@aggregators) { # last aggregator gets first shot
warn "Aggregator $a:\n" if $self->debug; $a->aggregate($features,$self); } } @$features;
| get_features_iterator | description | prev | next | Top |
my $self = shift; my ($search,$options,$callback) = @_; $self->throw('feature iteration is not implemented in this adaptor');}
| split_group | description | prev | next | Top |
my $self = shift; my ($group,$gff3) = @_; if ($gff3) { my @groups = split /[;&]/,$group; # so easy!}
return $self->_split_gff3_group(@groups); } else { # handle group parsing
# protect embedded semicolons in the group; there must be faster/more elegant way
# to do this.
$group =~ s/\\;/$;/g; while ($group =~ s/( \"[^\"]*);([^\"]*\")/$1$;$2/) { 1 } my @groups = split(/\s*;\s*/,$group); foreach (@groups) { s/$;/;/g } return $self->_split_gff2_group(@groups); }
| _split_gff2_group | description | prev | next | Top |
my $self = shift; my @groups = @_; my $target_found; my ($gclass,$gname,$tstart,$tstop,@attributes,@notes); for (@groups) { my ($tag,$value) = /^(\S+)(?:\s+(.+))?/; $value = '' unless defined $value; if ($value =~ /^\"(.+)\"$/) { #remove quotes}
$value = $1; } $value =~ s/\\t/\t/g; $value =~ s/\\r/\r/g; $value =~ s/\s+$//; # Any additional groups become part of the attributes hash
# For historical reasons, the tag "Note" is treated as an
# attribute, even if it is the only group.
$tag ||= ''; if ($tag eq 'tstart' && $target_found) { $tstart = $value; } elsif ($tag eq 'tend' && $target_found) { $tstop = $value; } elsif (ucfirst $tag eq 'Note') { push @notes, [$tag => $value]; } elsif ($tag eq 'Target' && /([^:\"\s]+):([^\"\s]+)/) { # major disagreement in implementors of GFF2 here
$target_found++; ($gclass,$gname) = ($1,$2); ($tstart,$tstop) = / (\d+) (\d+)/; } elsif (!defined($value)) { push @notes, [Note => $tag]; # e.g. "Confirmed_by_EST"
} else { push @attributes, [$tag => $value]; } } # group assignment
if (@attributes && !($gclass && $gname) ) { my $preferred = ref($self) ? $self->_preferred_groups_hash : {}; for my $pair (@attributes) { my ($c,$n) = @$pair; ($gclass,$gname) = ($c,$n) if !$gclass # pick up first one
|| ($preferred->{lc $gclass}||0) < ($preferred->{lc $c}||0); # pick up higher priority one
} @attributes = grep {$gclass ne $_->[0]} @attributes; } push @attributes, @notes; return ($gclass,$gname,$tstart,$tstop,\@attributes);
| gff3_name_munging | description | prev | next | Top |
my $self = shift; my $d = $self->{gff3_name_munging}; $self->{gff3_name_munging} = shift if @_; $d;}
| _split_gff3_group | description | prev | next | Top |
my $self = shift; my @groups = @_; my $dc = $self->default_class; my (%id,@attributes); for my $group (@groups) { my ($tag,$value) = split /=/,$group; $tag = unescape($tag); my @values = map {unescape($_)} split /,/,$value; # GFF2 traditionally did not distinguish between a feature's name}
# and the group it belonged to. This code is a transition between
# gff2 and the new parent/ID dichotomy in gff3.
if ($tag eq 'Parent') { my (@names,@classes); for (@values) { my ($name,$class) = $self->_gff3_name_munging($_,$dc); push @names,$name; push @classes,$class; } $id{$tag} = @names > 1 ? [\@names,\@classes] : [$names[0],$classes[0]]; } elsif ($tag eq 'ID' || $tag eq 'Name') { $id{$tag} = [$self->_gff3_name_munging(shift(@values),$dc)]; } elsif ($tag eq 'Target') { my ($gname,$tstart,$tstop) = split /\s+/,shift @values; $id{$tag} = [$self->_gff3_name_munging($gname,$dc),$tstart,$tstop]; } elsif ($tag =~ /synonym/i) { $tag = 'Alias'; } push @attributes,[$tag=>$_] foreach @values; } my $priorities = $self->_preferred_groups_hash(1); my ($gclass,$gname,$tstart,$tstop); for my $preferred (sort {$priorities->{lc $b}<=>$priorities->{lc $a}} keys %id) { unless (defined $gname) { ($gname,$gclass,$tstart,$tstop) = @{$id{$preferred}}; } } # set null gclass to empty string to preserve compatibility with
# programs that expect a defined gclass if no gname
$gclass ||= '' if defined $gname; return ($gclass,$gname,$tstart,$tstop,\@attributes); } # accomodation for wormbase style of class:name naming
| _gff3_name_munging | description | prev | next | Top |
my $self = shift; my ($name,$default_class) = @_; return ($name,$default_class) unless $self->gff3_name_munging; if ($name =~ /^(\w+):(.+)/) { return ($2,$1); } else { return ($name,$default_class); }}
| _delete_features | description | prev | next | Top |
my $self = shift; my @feature_ids = @_; $self->throw('_delete_features is not implemented in this adaptor');}
| _delete_groups | description | prev | next | Top |
my $self = shift; my @group_ids = @_; $self->throw('_delete_groups is not implemented in this adaptor');}
| _delete | description | prev | next | Top |
my $self = shift; my $delete_options = shift; $self->throw('_delete is not implemented in this adaptor');}
| _delete_fattribute_to_features | description | prev | next | Top |
my $self = shift; my @feature_ids = @_; $self->throw('_delete_fattribute_to_features is not implemented in this adaptor');}
| unescape | description | prev | next | Top |
my $v = shift; $v =~ tr/+/ /; $v =~ s/%([0-9a-fA-F]{2})/chr hex($1)/ge; return $v;}
| print_gff3_warning | description | prev | next | Top |
my $self = shift; print STDERR <<END}
You are loading a Bio::DB::GFF database with GFF3 formatted data. While this will likely work fine, the Bio::DB::GFF schema does not always faithfully capture the complexity represented in GFF3 files. Unless you have a specific reason for using Bio::DB::GFF, we suggest that you use a Bio::DB::SeqFeature::Store database and its corresponding loader, bp_seqfeature_load.pl. END ; return; } package Bio::DB::GFF::ID_Iterator; use strict; use base qw(Bio::Root::Root);
| API | Top |
| Querying GFF Databases | Top |
| get_Stream_by_batch () | Top |
Title : get_Stream_by_batchNOTE: This is the same as get_Stream_by_id().
Usage : $seq = $db->get_Stream_by_batch(@ids);
Function: Retrieves a stream of Seq objects given their ids
Returns : a Bio::SeqIO stream object
Args : an array of unique ids/accession numbers, or
an array reference
| Creating and Loading GFF Databases | Top |
| Methods for use by Subclasses | Top |
| Protected API | Top |
| feature_summary(), coverage_array() | Top |
| Internal Methods | Top |