Bio::DB::SeqFeature::Store::FeatureFileLoader(3pm) | User Contributed Perl Documentation | Bio::DB::SeqFeature::Store::FeatureFileLoader(3pm) |
Bio::DB::SeqFeature::Store::FeatureFileLoader -- feature file loader for Bio::DB::SeqFeature::Store
use Bio::DB::SeqFeature::Store; use Bio::DB::SeqFeature::Store::FeatureFileLoader; # Open the sequence database my $db = Bio::DB::SeqFeature::Store->new( -adaptor => 'DBI::mysql', -dsn => 'dbi:mysql:test', -write => 1 ); my $loader = Bio::DB::SeqFeature::Store::FeatureFileLoader->new(-store => $db, -verbose => 1, -fast => 1); $loader->load('./my_genome.fff');
The Bio::DB::SeqFeature::Store::FeatureFileLoader object parsers FeatureFile-format sequence annotation files and loads Bio::DB::SeqFeature::Store databases. For certain combinations of SeqFeature classes and SeqFeature::Store databases it features a "fast load" mode which will greatly accelerate the loading of databases by a factor of 5-10.
FeatureFile Format (.fff) is very simple:
mRNA B0511.1 Chr1:1..100 Type=UTR;Note="putative primase" mRNA B0511.1 Chr1:101..200,300..400,500..800 Type=CDS mRNA B0511.1 Chr1:801..1000 Type=UTR reference = Chr3 Cosmid B0511 516..619 Cosmid B0511 3185..3294 Cosmid B0511 10946..11208 Cosmid B0511 13126..13511 Cosmid B0511 11394..11539 EST yk260e10.5 15569..15724 EST yk672a12.5 537..618,3187..3294 EST yk595e6.5 552..618 EST yk595e6.5 3187..3294 EST yk846e07.3 11015..11208 EST yk53c10 yk53c10.3 15000..15500,15700..15800 yk53c10.5 18892..19154 EST yk53c10.5 16032..16105 SwissProt PECANEX 13153-13656 Note="Swedish fish" FGENESH "Predicted gene 1" 1-205,518-616,661-735,3187-3365,3436-3846 "Pfam domain" # file ends
There are up to four columns of WHITESPACE (not necessarily tab) delimited text. Embedded whitespace must be escaped using shell escaping rules (quoting the column or backslashing whitespace).
Column 1: The feature type. You may use type:subtype as a convention for method:source. Column 2: The feature name/ID. Column 3: The position of this feature in base pair coordinates. Ranges can be given as either start-end or start..end. A chromosome position can be specified using the format "reference:start..end". A discontinuous feature can be specified by giving multiple ranges separated by commas. Minus-strand features are indicated by specifying a start > end. Column 4: Comment/attribute field. A single Note can be given, or a series of attribute=value pairs, separated by spaces or semicolons, as in "score=23;type=transmembrane"
A feature position is specified using a sequence ID (a genbank accession number, a chromosome name, a contig, or any other meaningful reference system, followed by a colon and a position range. Ranges are two integers separated by double dots or the hyphen. Examples: "Chr1:516..11208", "ctgA:1-5000". Negative coordinates are allowed, as in "Chr1:-187..1000".
A discontinuous range ("split location") uses commas to separate the ranges. For example:
Gene B0511.1 Chr1:516..619,3185..3294,10946..11208
In the case of a split location, the sequence id only has to appear in front of the first range.
Alternatively, a split location can be indicated by repeating the features type and name on multiple adjacent lines:
Gene B0511.1 Chr1:516..619 Gene B0511.1 Chr1:3185..3294 Gene B0511.1 Chr1:10946..11208
If all the locations are on the same reference sequence, you can specify a default chromosome using a "reference=<seqid>":
reference=Chr1 Gene B0511.1 516..619 Gene B0511.1 3185..3294 Gene B0511.1 10946..11208
The default seqid is in effect until the next "reference" line appears.
Tags can be added to features by adding a fourth column consisting of "tag=value" pairs:
Gene B0511.1 Chr1:516..619,3185..3294 Note="Putative primase"
Tags and their values take any form you want, and multiple tags can be separated by semicolons. You can also repeat tags multiple times:
Gene B0511.1 Chr1:516..619,3185..3294 GO_Term=GO:100;GO_Term=GO:2087
Several tags have special meanings:
Tag Meaning --- ------- Type The primary tag for a subfeature. Score The score of a feature or subfeature. Phase The phase of a feature or subfeature. URL A URL to link to (via the Bio::Graphics library). Note A note to attach to the feature for display by the Bio::Graphics library.
For example, in the common case of an mRNA, you can use the "Type" tag to distinguish the parts of the mRNA into UTR and CDS:
mRNA B0511.1 Chr1:1..100 Type=UTR mRNA B0511.1 Chr1:101..200,300..400,500..800 Type=CDS mRNA B0511.1 Chr1:801..1000 Type=UTR
The top level feature's primary tag will be "mRNA", and its subparts will have types UTR and CDS as indicated. Additional tags that are placed in the first line of the feature will be applied to the top level. In this example, the note "Putative primase" will be applied to the mRNA at the top level of the feature:
mRNA B0511.1 Chr1:1..100 Type=UTR;Note="Putative primase" mRNA B0511.1 Chr1:101..200,300..400,500..800 Type=CDS mRNA B0511.1 Chr1:801..1000 Type=UTR
Features can be grouped so that they are rendered by the "group" glyph. To start a group, create a two-column feature entry showing the group type and a name for the group. Follow this with a list of feature entries with a blank type. For example:
EST yk53c10 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.
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.
The special comment "#include 'filename'" acts like the C preprocessor directive and will insert the comments of a named file into the position at which it occurs. Relative paths will be treated relative to the file in which the #include occurs. Nested #include directives are allowed:
#include "/usr/local/share/my_directives.txt" #include 'my_directives.txt' #include chromosome3_features.gff3
You can enclose the file path in single or double quotes as shown above. If there are no spaces in the filename the quotes are optional.
Include file processing is not very smart. Avoid creating circular #include references. You have been warned!
Note that this loader always creates denormalized features such that subfeatures and their parents are stored as one big database object. The GFF3 format and its loader is usually preferred for both space and execution efficiency.
Title : new Usage : $loader = Bio::DB::SeqFeature::Store::FeatureFileLoader->new(@options) Function: create a new parser Returns : a Bio::DB::SeqFeature::Store::FeatureFileLoader parser and loader Args : several - see below Status : public
This method creates a new FeatureFile loader and establishes its connection with a Bio::DB::SeqFeature::Store database. Arguments are -name=>$value pairs as described in this table:
Name Value ---- ----- -store A writable Bio::DB::SeqFeature::Store database handle. -seqfeature_class The name of the type of Bio::SeqFeatureI object to create and store in the database (Bio::DB::SeqFeature by default) -sf_class A shorter alias for -seqfeature_class -verbose Send progress information to standard error. -fast If true, activate fast loading (see below) -chunk_size Set the storage chunk size for nucleotide/protein sequences (default 2000 bytes) -tmp Indicate a temporary directory to use when loading non-normalized features.
When you call new(), a connection to a Bio::DB::SeqFeature::Store database should already have been established and the database initialized (if appropriate).
Some combinations of Bio::SeqFeatures and Bio::DB::SeqFeature::Store databases support a fast loading mode. Currently the only reliable implementation of fast loading is the combination of DBI::mysql with Bio::DB::SeqFeature. The other important restriction on fast loading is the requirement that a feature that contains subfeatures must occur in the FeatureFile file before any of its subfeatures. Otherwise the subfeatures that occurred before the parent feature will not be attached to the parent correctly. This restriction does not apply to normal (slow) loading.
If you use an unnormalized feature class, such as Bio::SeqFeature::Generic, then the loader needs to create a temporary database in which to cache features until all their parts and subparts have been seen. This temporary databases uses the "bdb" adaptor. The -tmp option specifies the directory in which that database will be created. If not present, it defaults to the system default tmp directory specified by File::Spec->tmpdir().
The -chunk_size option allows you to tune the representation of DNA/Protein sequence in the Store database. By default, sequences are split into 2000 base/residue chunks and then reassembled as needed. This avoids the problem of pulling a whole chromosome into memory in order to fetch a short subsequence from somewhere in the middle. Depending on your usage patterns, you may wish to tune this parameter using a chunk size that is larger or smaller than the default.
Title : load Usage : $count = $loader->load(@ARGV) Function: load the indicated files or filehandles Returns : number of feature lines loaded Args : list of files or filehandles Status : public
Once the loader is created, invoke its load() method with a list of FeatureFile or FASTA file paths or previously-opened filehandles in order to load them into the database. Compressed files ending with .gz, .Z and .bz2 are automatically recognized and uncompressed on the fly. Paths beginning with http: or ftp: are treated as URLs and opened using the LWP GET program (which must be on your path).
FASTA files are recognized by their initial ">" character. Do not feed the loader a file that is neither FeatureFile nor FASTA; I don't know what will happen, but it will probably not be what you expect.
The following read-only accessors return values passed or created during new():
store() the long-term Bio::DB::SeqFeature::Store object tmp_store() the temporary Bio::DB::SeqFeature::Store object used during loading sfclass() the Bio::SeqFeatureI class fast() whether fast loading is active seq_chunk_size() the sequence chunk size verbose() verbose progress messages
$class = $loader->default_seqfeature_class
Return the default SeqFeatureI class (Bio::Graphics::Feature).
$count = $loader->load_fh($filehandle)
Load the FeatureFile data at the other end of the filehandle and return true if successful. Internally, load_fh() invokes:
start_load(); do_load($filehandle); finish_load();
These methods are called at the start and end of a filehandle load.
$loader->load_line($data);
Load a line of a FeatureFile file. You must bracket this with calls to start_load() and finish_load()!
$loader->start_load(); $loader->load_line($_) while <FH>; $loader->finish_load();
$loader->handle_meta($meta_directive)
This method is called to handle meta-directives such as ##sequence-region. The method will receive the directive with the initial ## stripped off.
$loader->handle_feature($gff3_line)
This method is called to process a single FeatureFile line. It manipulates information stored a data structure called $self->{load_data}.
$loader->store_current_feature()
This method is called to store the currently active feature in the database. It uses a data structure stored in $self->{load_data}.
$loader->build_object_tree()
This method gathers together features and subfeatures and builds the graph that connects them.
$loader->build_object_tree_in_tables()
This method gathers together features and subfeatures and builds the graph that connects them, assuming that parent/child relationships will be stored in a database table.
$loader->build_object_tree_in_features()
This method gathers together features and subfeatures and builds the graph that connects them, assuming that parent/child relationships are stored in the seqfeature objects themselves.
$loader->attach_children($store,$load_data,$load_id,$feature)
This recursively adds children to features and their subfeatures. It is called when subfeatures are directly contained within other features, rather than stored in a relational table.
@attributes = $loader->parse_attributes($attribute_line)
This method parses the information contained in the $attribute_line into a flattened hash (array). It may return one element, in which case it is an implicit
$loader->start_or_finish_sequence('Chr9')
This method is called at the beginning and end of a fasta section.
This is an early version, so there are certainly some bugs. Please use the BioPerl bug tracking system to report bugs.
Bio::DB::SeqFeature::Store, Bio::DB::SeqFeature::Segment, Bio::DB::SeqFeature::NormalizedFeature, Bio::DB::SeqFeature::GFF3Loader, Bio::DB::SeqFeature::Store::DBI::mysql, Bio::DB::SeqFeature::Store::bdb
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2006 Cold Spring Harbor Laboratory.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2018-10-27 | perl v5.26.2 |