.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Bio::SeqFeature::Tools::Unflattener 3pm" .TH Bio::SeqFeature::Tools::Unflattener 3pm "2021-08-15" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Bio::SeqFeature::Tools::Unflattener \- turns flat list of genbank\-sourced features into a nested SeqFeatureI hierarchy .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # standard / generic use \- unflatten a genbank record \& use Bio::SeqIO; \& use Bio::SeqFeature::Tools::Unflattener; \& \& # generate an Unflattener object \& $unflattener = Bio::SeqFeature::Tools::Unflattener\->new; \& \& # first fetch a genbank SeqI object \& $seqio = \& Bio::SeqIO\->new(\-file=>\*(AqAE003644.gbk\*(Aq, \& \-format=>\*(AqGenBank\*(Aq); \& my $out = \& Bio::SeqIO\->new(\-format=>\*(Aqasciitree\*(Aq); \& while ($seq = $seqio\->next_seq()) { \& \& # get top level unflattended SeqFeatureI objects \& $unflattener\->unflatten_seq(\-seq=>$seq, \& \-use_magic=>1); \& $out\->write_seq($seq); \& \& @top_sfs = $seq\->get_SeqFeatures; \& foreach my $sf (@top_sfs) { \& # do something with top\-level features (eg genes) \& } \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Most GenBank entries for annotated genomic \s-1DNA\s0 contain a \fBflat\fR list of features. These features can be parsed into an equivalent flat list of Bio::SeqFeatureI objects using the standard Bio::SeqIO classes. However, it is often desirable to \fBunflatten\fR this list into something resembling actual \fBgene models\fR, in which genes, mRNAs and CDSs are \fBnested\fR according to the nature of the gene model. .PP The BioPerl object model allows us to store these kind of associations between SeqFeatures in \fBcontainment hierarchies\fR \*(-- any SeqFeatureI object can contain nested SeqFeatureI objects. The Bio::SeqFeature::Tools::Unflattener object facilitates construction of these hierarchies from the underlying GenBank flat-feature-list representation. .PP For example, if you were to look at a typical GenBank \s-1DNA\s0 entry, say, \&\fB\s-1AE003644\s0\fR, you would see a flat list of features: .PP .Vb 1 \& source \& \& gene CG4491 \& mRNA CG4491\-RA \& CDS CG4491\-PA \& \& gene tRNA\-Pro \& tRNA tRNA\-Pro \& \& gene CG32954 \& mRNA CG32954\-RA \& mRNA CG32954\-RC \& mRNA CG32954\-RB \& CDS CG32954\-PA \& CDS CG32954\-PB \& CDS CG32954\-PC .Ve .PP These features have sequence locations, but it is not immediately clear how to write code such that each mRNA is linked to the appropriate \s-1CDS\s0 (other than relying on IDs which is very bad) .PP We would like to convert the above list into the \fBcontainment hierarchy\fR, shown below: .PP .Vb 10 \& source \& gene \& mRNA CG4491\-RA \& CDS CG4491\-PA \& exon \& exon \& gene \& tRNA tRNA\-Pro \& exon \& gene \& mRNA CG32954\-RA \& CDS CG32954\-PA \& exon \& exon \& mRNA CG32954\-RC \& CDS CG32954\-PC \& exon \& exon \& mRNA CG32954\-RB \& CDS CG32954\-PB \& exon \& exon .Ve .PP Where each feature is nested underneath its container. Note that exons have been automatically inferred (even for tRNA genes). .PP We do this using a call on a Bio::SeqFeature::Tools::Unflattener object .PP .Vb 1 \& @sfs = $unflattener\->unflatten_seq(\-seq=>$seq); .Ve .PP This would return a list of the \fBtop level\fR (i.e. container) SeqFeatureI objects \- in this case, genes. Other top level features are possible; for instance, the \fBsource\fR feature which is always present, and other features such as \fBvariation\fR or \fBmisc_feature\fR types. .PP The containment hierarchy can be accessed using the \fBget_SeqFeature()\fR call on any feature object \- see Bio::SeqFeature::FeatureHolderI. The following code will traverse the containment hierarchy for a feature: .PP .Vb 2 \& sub traverse { \& $sf = shift; # $sf isa Bio::SeqfeatureI \& \& # ...do something with $sf! \& \& # depth first traversal of containment tree \& @contained_sfs = $sf\->get_SeqFeatures; \& traverse($_) foreach @contained_sfs; \& } .Ve .PP Once you have built the hierarchy, you can do neat stuff like turn the features into 'rich' feature objects (eg Bio::SeqFeature::Gene::GeneStructure) or convert to a suitable format such as \s-1GFF3\s0 or chadoxml (after mapping to the Sequence Ontology); this step is not described here. .SH "USING MAGIC" .IX Header "USING MAGIC" Due to the quixotic nature of how features are stored in GenBank/EMBL/DDBJ, there is no guarantee that the default behaviour of this module will produce perfect results. Sometimes it is hard or impossible to build a correct containment hierarchy if the information provided is simply too lossy, as is often the case. If you care deeply about your data, you should always manually inspect the resulting containment hierarchy; you may have to customise the algorithm for building the hierarchy, or even manually tweak the resulting hierarchy. This is explained in more detail further on in the document. .PP However, if you are satisfied with the default behaviour, then you do not need to read any further. Just make sure you set the parameter \&\fBuse_magic\fR \- this will invoke incantations which will magically produce good results no matter what the idiosyncracies of the particular GenBank record in question. .PP For example .PP .Vb 2 \& $unflattener\->unflatten_seq(\-seq=>$seq, \& \-use_magic=>1); .Ve .PP The success of this depends on the phase of the moon at the time the entry was submitted to GenBank. Note that the magical recipe is being constantly improved, so the results of invoking magic may vary depending on the bioperl release. .PP If you are skeptical of magic, or you wish to exact fine grained control over how the entry is unflattened, or you simply wish to understand more about how this crazy stuff works, then read on! .SH "PROBLEMATIC DATA AND INCONSISTENCIES" .IX Header "PROBLEMATIC DATA AND INCONSISTENCIES" Occasionally the Unflattener will have problems with certain records. For example, the record may contain inconsistent data \- maybe there is an \fBexon\fR entry that has no corresponding \fBmRNA\fR location. .PP The default behaviour is to throw an exception reporting the problem, if the problem is relatively serious \- for example, inconsistent data. .PP You can exert more fine grained control over this \- perhaps you want the Unflattener to do the best it can, and report any problems. This can be done \- refer to the methods. .PP .Vb 1 \& error_threshold() \& \& get_problems() \& \& report_problems() \& \& ignore_problems() .Ve .SH "ALGORITHM" .IX Header "ALGORITHM" This is the default algorithm; you should be able to override any part of it to customise. .PP The core of the algorithm is in two parts .IP "Partitioning the flat feature list into groups" 4 .IX Item "Partitioning the flat feature list into groups" .PD 0 .IP "Resolving the feature containment hierarchy for each group" 4 .IX Item "Resolving the feature containment hierarchy for each group" .PD .PP There are other optional steps after the completion of these two steps, such as \fBinferring exons\fR; we now describe in more detail what is going on. .SS "Partitioning into groups" .IX Subsection "Partitioning into groups" First of all the flat feature list is partitioned into \fBgroup\fRs. .PP The default way of doing this is to use the \fBgene\fR attribute; if we look at two features from GenBank accession \s-1AE003644.3:\s0 .PP .Vb 11 \& gene 20111..23268 \& /gene="noc" \& /locus_tag="CG4491" \& /note="last curated on Thu Dec 13 16:51:32 PST 2001" \& /map="35B2\-35B2" \& /db_xref="FLYBASE:FBgn0005771" \& mRNA join(20111..20584,20887..23268) \& /gene="noc" \& /locus_tag="CG4491" \& /product="CG4491\-RA" \& /db_xref="FLYBASE:FBgn0005771" .Ve .PP Both these features share the same /gene tag which is \*(L"noc\*(R", so they correspond to the same gene model (the \s-1CDS\s0 feature is not shown, but this also has a tag-value /gene=\*(L"noc\*(R"). .PP Not all groups need to correspond to gene models, but this is the most common use case; later on we shall describe how to customise the grouping. .PP Sometimes other tags have to be used; for instance, if you look at the entire record for \s-1AE003644.3\s0 you will see you actually need the use the /locus_tag attribute. This attribute is actually \fBnot present\fR in most records! .PP You can override this: .PP .Vb 1 \& $collection\->unflatten_seq(\-seq=>$seq, \-group_tag=>\*(Aqlocus_tag\*(Aq); .Ve .PP Alternatively, if you \fB\-use_magic\fR, the object will try and make a guess as to what the correct group_tag should be. .PP At the end of this step, we should have a list of groups \- there is no structure within a group; the group just serves to partition the flat features. For the example data above, we would have the following groups. .PP .Vb 5 \& [ source ] \& [ gene mRNA CDS ] \& [ gene mRNA CDS ] \& [ gene mRNA CDS ] \& [ gene mRNA mRNA mRNA CDS CDS CDS ] .Ve .PP \fIMulticopy Genes\fR .IX Subsection "Multicopy Genes" .PP Multicopy genes are usually rRNAs or tRNAs that are duplicated across the genome. Because they are functionally equivalent, and usually have the same sequence, they usually have the same group_tag (ie gene symbol); they often have a /note tag giving copy number. This means they will end up in the same group. This is undesirable, because they are spatially disconnected. .PP There is another step, which involves splitting spatially disconnected groups into distinct groups .PP this would turn this .PP .Vb 1 \& [gene\-rrn3 rRNA\-rrn3 gene\-rrn3 rRNA\-rrn3] .Ve .PP into this .PP .Vb 1 \& [gene\-rrn3 rRNA\-rrn3] [gene\-rrn3 rRNA\-rrn3] .Ve .PP based on the coordinates .PP \fIWhat next?\fR .IX Subsection "What next?" .PP The next step is to add some structure to each group, by making \&\fBcontainment hierarchies\fR, trees that represent how the features interrelate .SS "Resolving the containment hierarchy" .IX Subsection "Resolving the containment hierarchy" After the grouping is done, we end up with a list of groups which probably contain features of type 'gene', 'mRNA', '\s-1CDS\s0' and so on. .PP Singleton groups (eg the 'source' feature) are ignored at this stage. .PP Each group is itself flat; we need to add an extra level of organisation. Usually this is because different spliceforms (represented by the 'mRNA' feature) can give rise to different protein products (indicated by the '\s-1CDS\s0' feature). We want to correctly associate mRNAs to CDSs. .PP We want to go from a group like this: .PP .Vb 1 \& [ gene mRNA mRNA mRNA CDS CDS CDS ] .Ve .PP to a containment hierarchy like this: .PP .Vb 7 \& gene \& mRNA \& CDS \& mRNA \& CDS \& mRNA \& CDS .Ve .PP In which each \s-1CDS\s0 is nested underneath the correct corresponding mRNA. .PP For entries that contain no alternate splicing, this is simple; we know that the group .PP .Vb 1 \& [ gene mRNA CDS ] .Ve .PP Must resolve to the tree .PP .Vb 3 \& gene \& mRNA \& CDS .Ve .PP How can we do this in entries with alternate splicing? The bad news is that there is no guaranteed way of doing this correctly for any GenBank entry. Occasionally the submission will have been done in such a way as to reconstruct the containment hierarchy. However, this is not consistent across databank entries, so no generic solution can be provided by this object. This module does provide the framework within which you can customise a solution for the particular dataset you are interested in \- see later. .PP The good news is that there is an inference we can do that should produce pretty good results the vast majority of the time. It uses splice coordinate data \- this is the default behaviour of this module, and is described in detail below. .SS "Using splice site coordinates to infer containment" .IX Subsection "Using splice site coordinates to infer containment" If an mRNA is to be the container for a \s-1CDS,\s0 then the splice site coordinates (or intron coordinates, depending on how you look at it) of the \s-1CDS\s0 must fit inside the splice site coordinates of the mRNA. .PP Ambiguities can still arise, but the results produced should still be reasonable and consistent at the sequence level. Look at this fake example: .PP .Vb 4 \& mRNA XXX\-\-\-XX\-\-XXXXXX\-\-XXXX join(1..3,7..8,11..16,19..23) \& mRNA XXX\-\-\-\-\-\-\-XXXXXX\-\-XXXX join(1..3,11..16,19..23) \& CDS XXXX\-\-XX join(13..16,19..20) \& CDS XXXX\-\-XX join(13..16,19..20) .Ve .PP [obviously the positions have been scaled down] .PP We cannot unambiguously match mRNA with \s-1CDS\s0 based on splice sites, since both \s-1CDS\s0 share the splice site locations 16^17 and 18^19. However, the consequences of making a wrong match are probably not very severe. Any annotation data attached to the first \s-1CDS\s0 is probably identical to the seconds \s-1CDS,\s0 other than identifiers. .PP The default behaviour of this module is to make an arbitrary call where it is ambiguous (the mapping will always be bijective; i.e. one mRNA \-> one \s-1CDS\s0). .PP [\s-1TODO: NOTE:\s0 not tested on \s-1EMBL\s0 data, which may not be bijective; ie two mRNAs can share the same \s-1CDS\s0??] .PP This completes the building of the containment hierarchy; other optional step follow .SH "POST-GROUPING STEPS" .IX Header "POST-GROUPING STEPS" .SS "Inferring exons from mRNAs" .IX Subsection "Inferring exons from mRNAs" This step always occurs if \fB\-use_magic\fR is invoked. .PP In a typical GenBank entry, the exons are \fBimplicit\fR. That is they can be inferred from the mRNA location. .PP For example: .PP .Vb 1 \& mRNA join(20111..20584,20887..23268) .Ve .PP This tells us that this particular transcript has two exons. In bioperl, the mRNA feature will have a 'split location'. .PP If we call .PP .Vb 1 \& $unflattener\->feature_from_splitloc(\-seq=>$seq); .Ve .PP This will generate the necessary exon features, and nest them under the appropriate mRNAs. Note that the mRNAs will no longer have split locations \- they will have simple locations spanning the extent of the exons. This is intentional, to avoid redundancy. .PP Occasionally a GenBank entry will have both implicit exons (from the mRNA location) \fBand\fR explicit exon features. .PP In this case, exons will still be transferred. Tag-value data from the explicit exon will be transferred to the implicit exon. If exons are shared between mRNAs these will be represented by different objects. Any inconsistencies between implicit and explicit will be reported. .PP \fItRNAs and other noncoding RNAs\fR .IX Subsection "tRNAs and other noncoding RNAs" .PP exons will also be generated from these features .SS "Inferring mRNAs from \s-1CDS\s0" .IX Subsection "Inferring mRNAs from CDS" Some GenBank entries represent gene models using features of type gene, mRNA and \s-1CDS\s0; some entries just use gene and \s-1CDS.\s0 .PP If we only have gene and \s-1CDS,\s0 then the containment hierarchies will look like this: .PP .Vb 2 \& gene \& CDS .Ve .PP If we want the containment hierarchies to be uniform, like this .PP .Vb 3 \& gene \& mRNA \& CDS .Ve .PP Then we must create an mRNA feature. This will have identical coordinates to the \s-1CDS.\s0 The assumption is that there is either no untranslated region, or it is unknown. .PP To do this, we can call .PP .Vb 1 \& $unflattener\->infer_mRNA_from_CDS(\-seq=>$seq); .Ve .PP This is taken care of automatically, if \fB\-use_magic\fR is invoked. .SH "ADVANCED" .IX Header "ADVANCED" .SS "Customising the grouping of features" .IX Subsection "Customising the grouping of features" The default behaviour is suited mostly to building models of protein coding genes and noncoding genes from genbank genomic \s-1DNA\s0 submissions. .PP You can change the tag used to partition the feature by passing in a different group_tag argument \- see the \fBunflatten_seq()\fR method .PP Other behaviour may be desirable. For example, even though SNPs (features of type 'variation' in GenBank) are not actually part of the gene model, it may be desirable to group SNPs that overlap or are nearby gene models. .PP It should certainly be possible to extend this module to do this. However, I have yet to code this part!!! If anyone would find this useful let me know. .PP In the meantime, you could write your own grouping subroutine, and feed the results into \fBunflatten_groups()\fR [see the method documentation below] .SS "Customising the resolution of the containment hierarchy" .IX Subsection "Customising the resolution of the containment hierarchy" Once the flat list of features has been partitioned into groups, the method \fBunflatten_group()\fR is called on each group to build a tree. .PP The algorithm for doing this is described above; ambiguities are resolved by using splice coordinates. As discussed, this can be ambiguous. .PP Some submissions may contain information in tags/attributes that hint as to the mapping that needs to be made between the features. .PP For example, with the Drosophila Melanogaster release 3 submission, we see that \s-1CDS\s0 features in alternately spliced mRNAs have a form like this: .PP .Vb 10 \& CDS join(145588..145686,145752..146156,146227..146493) \& /locus_tag="CG32954" \& /note="CG32954 gene product from transcript CG32954\-RA" \& ^^^^^^^^^^^^^^^^^^^^^^^^^^^ \& /codon_start=1 \& /product="CG32954\-PA" \& /protein_id="AAF53403.1" \& /db_xref="GI:7298167" \& /db_xref="FLYBASE:FBgn0052954" \& /translation="MSFTLTNKNVIFVAGLGGIGLDTSKELLKRDLKNLVILDRIENP..." .Ve .PP Here the /note tag provides the clue we need to link \s-1CDS\s0 to mRNA (highlighted with ^^^^). We just need to find the mRNA with the tag .PP .Vb 1 \& /product="CG32954\-RA" .Ve .PP I have no idea how consistent this practice is across submissions; it is consistent for the fruitfly genome submission. .PP We can customise the behaviour of \fBunflatten_group()\fR by providing our own resolver method. This obviously requires a bit of extra programming, but there is no way to get around this. .PP Here is an example of how to pass in your own resolver; this example basically checks the parent (container) /product tag to see if it matches the required string in the child (contained) /note tag. .PP .Vb 10 \& $unflattener\->unflatten_seq(\-seq=>$seq, \& \-group_tag=>\*(Aqlocus_tag\*(Aq, \& \-resolver_method=>sub { \& my $self = shift; \& my ($sf, @candidate_container_sfs) = @_; \& if ($sf\->has_tag(\*(Aqnote\*(Aq)) { \& my @notes = $sf\->get_tag_values(\*(Aqnote\*(Aq); \& my @trnames = map {/from transcript\es+(.*)/; \& $1} @notes; \& @trnames = grep {$_} @trnames; \& my $trname; \& if (@trnames == 0) { \& $self\->throw("UNRESOLVABLE"); \& } \& elsif (@trnames == 1) { \& $trname = $trnames[0]; \& } \& else { \& $self\->throw("AMBIGUOUS: @trnames"); \& } \& my @container_sfs = \& grep { \& my ($product) = \& $_\->has_tag(\*(Aqproduct\*(Aq) ? \& $_\->get_tag_values(\*(Aqproduct\*(Aq) : \& (\*(Aq\*(Aq); \& $product eq $trname; \& } @candidate_container_sfs; \& if (@container_sfs == 0) { \& $self\->throw("UNRESOLVABLE"); \& } \& elsif (@container_sfs == 1) { \& # we got it! \& return $container_sfs[0]; \& } \& else { \& $self\->throw("AMBIGUOUS"); \& } \& } \& }); .Ve .PP the resolver method is only called when there is more than one spliceform. .SS "Parsing mRNA records" .IX Subsection "Parsing mRNA records" Some of the entries in sequence databanks are for mRNA sequences as well as genomic \s-1DNA.\s0 We may want to build models from these too. .PP \&\s-1NOT YET DONE\s0 \- \s-1IN PROGRESS\s0!!! .PP Open question \- what would these look like? .PP Ideally we would like a way of combining a mRNA record with the corresponding SeFeature entry from the appropriate genomic \s-1DNA\s0 record. This could be problemmatic in some cases \- for example, the mRNA sequences may not match 100% (due to differences in strain, assembly problems, sequencing problems, etc). What then...? .SH "SEE ALSO" .IX Header "SEE ALSO" Feature table description .PP .Vb 1 \& http://www.ebi.ac.uk/embl/Documentation/FT_definitions/feature_table.html .Ve .SH "FEEDBACK" .IX Header "FEEDBACK" .SS "Mailing Lists" .IX Subsection "Mailing Lists" User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing lists Your participation is much appreciated. .PP .Vb 2 \& bioperl\-l@bioperl.org \- General discussion \& http://bioperl.org/wiki/Mailing_lists \- About the mailing lists .Ve .SS "Support" .IX Subsection "Support" Please direct usage questions or support issues to the mailing list: .PP \&\fIbioperl\-l@bioperl.org\fR .PP rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. .SS "Reporting Bugs" .IX Subsection "Reporting Bugs" report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: .PP .Vb 1 \& https://github.com/bioperl/bioperl\-live/issues .Ve .SH "AUTHOR \- Chris Mungall" .IX Header "AUTHOR - Chris Mungall" Email: cjm@fruitfly.org .SH "APPENDIX" .IX Header "APPENDIX" The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ .SS "new" .IX Subsection "new" .Vb 7 \& Title : new \& Usage : $unflattener = Bio::SeqFeature::Tools::Unflattener\->new(); \& $unflattener\->unflatten_seq(\-seq=>$seq); \& Function: constructor \& Example : \& Returns : a new Bio::SeqFeature::Tools::Unflattener \& Args : see below .Ve .PP Arguments .PP .Vb 3 \& \-seq : A L object (optional) \& the sequence to unflatten; this can also be passed in \& when we call unflatten_seq() \& \& \-group_tag : a string representing the /tag used to partition flat features \& (see discussion above) .Ve .SS "seq" .IX Subsection "seq" .Vb 6 \& Title : seq \& Usage : $unflattener\->seq($newval) \& Function: \& Example : \& Returns : value of seq (a Bio::SeqI) \& Args : on set, new value (a Bio::SeqI, optional) .Ve .PP The Bio::SeqI object should hold a flat list of Bio::SeqFeatureI objects; this is the list that will be unflattened. .PP The sequence object can also be set when we call \fBunflatten_seq()\fR .SS "group_tag" .IX Subsection "group_tag" .Vb 6 \& Title : group_tag \& Usage : $unflattener\->group_tag($newval) \& Function: \& Example : \& Returns : value of group_tag (a scalar) \& Args : on set, new value (a scalar or undef, optional) .Ve .PP This is the tag that will be used to collect elements from the flat feature list into groups; for instance, if we look at two typical GenBank features: .PP .Vb 11 \& gene 20111..23268 \& /gene="noc" \& /locus_tag="CG4491" \& /note="last curated on Thu Dec 13 16:51:32 PST 2001" \& /map="35B2\-35B2" \& /db_xref="FLYBASE:FBgn0005771" \& mRNA join(20111..20584,20887..23268) \& /gene="noc" \& /locus_tag="CG4491" \& /product="CG4491\-RA" \& /db_xref="FLYBASE:FBgn0005771" .Ve .PP We can see that these comprise the same gene model because they share the same /gene attribute; we want to collect these together in groups. .PP Setting group_tag is optional. The default is to use 'gene'. In the example above, we could also use /locus_tag .SS "partonomy" .IX Subsection "partonomy" .Vb 6 \& Title : partonomy \& Usage : $unflattener\->partonomy({mRNA=>\*(Aqgene\*(Aq, CDS=>\*(AqmRNA\*(Aq) \& Function: \& Example : \& Returns : value of partonomy (a scalar) \& Args : on set, new value (a scalar or undef, optional) .Ve .PP A hash representing the containment structure that the seq_feature nesting should conform to; each key represents the contained (child) type; each value represents the container (parent) type. .SS "structure_type" .IX Subsection "structure_type" .Vb 6 \& Title : structure_type \& Usage : $unflattener\->structure_type($newval) \& Function: \& Example : \& Returns : value of structure_type (a scalar) \& Args : on set, new value (an int or undef, optional) .Ve .PP GenBank entries conform to different flavours, or \fBstructure types\fR. Some have mRNAs, some do not. .PP Right now there are only two base structure types defined. If you set the structure type, then appropriate unflattening action will be taken. The presence or absence of explicit exons does not affect the structure type. .PP If you invoke \fB\-use_magic\fR then this will be set automatically, based on the content of the record. .IP "Type 0 (\s-1DEFAULT\s0)" 4 .IX Item "Type 0 (DEFAULT)" typically contains .Sp .Vb 4 \& source \& gene \& mRNA \& CDS .Ve .Sp with this structure type, we want the seq_features to be nested like this .Sp .Vb 4 \& gene \& mRNA \& CDS \& exon .Ve .Sp exons and introns are implicit from the mRNA 'join' location .Sp to get exons from the mRNAs, you will need this call (see below) .Sp .Vb 1 \& $unflattener\->feature_from_splitloc(\-seq=>$seq); .Ve .IP "Type 1" 4 .IX Item "Type 1" typically contains .Sp .Vb 5 \& source \& gene \& CDS \& exon [optional] \& intron [optional] .Ve .Sp there are no mRNA features .Sp with this structure type, we want the seq_features to be nested like this .Sp .Vb 4 \& gene \& CDS \& exon \& intron .Ve .Sp exon and intron may or may not be present; they may be implicit from the \s-1CDS\s0 'join' location .SS "get_problems" .IX Subsection "get_problems" .Vb 6 \& Title : get_problems \& Usage : @probs = get_problems() \& Function: Get the list of problem(s) for this object. \& Example : \& Returns : An array of [severity, description] pairs \& Args : .Ve .PP In the course of unflattening a record, problems may occur. Some of these problems are non-fatal, and can be ignored. .PP Problems are represented as arrayrefs containing a pair [severity, description] .PP severity is a number, the higher, the more severe the problem .PP the description is a text string .SS "clear_problems" .IX Subsection "clear_problems" .Vb 6 \& Title : clear_problems \& Usage : \& Function: resets the problem list to empty \& Example : \& Returns : \& Args : .Ve .SS "report_problems" .IX Subsection "report_problems" .Vb 6 \& Title : report_problems \& Usage : $unflattener\->report_problems(\e*STDERR); \& Function: \& Example : \& Returns : \& Args : FileHandle (defaults to STDERR) .Ve .SS "ignore_problems" .IX Subsection "ignore_problems" .Vb 6 \& Title : ignore_problems \& Usage : $obj\->ignore_problems(); \& Function: \& Example : \& Returns : \& Args : .Ve .PP Unflattener is very particular about problems it finds along the way. If you have set the error_threshold such that less severe problems do not cause exceptions, Unflattener still expects you to \&\fBreport_problems()\fR at the end, so that the user of the module is aware of any inconsistencies or problems with the data. In fact, a warning will be produced if there are unreported problems. To silence, this warning, call the \fBignore_problems()\fR method before the Unflattener object is destroyed. .SS "error_threshold" .IX Subsection "error_threshold" .Vb 6 \& Title : error_threshold \& Usage : $obj\->error_threshold($severity) \& Function: \& Example : \& Returns : value of error_threshold (a scalar) \& Args : on set, new value (an integer) .Ve .PP Sets the threshold above which errors cause this module to throw an exception. The default is 0; all problems with a severity > 0 will cause an exception. .PP If you raise the threshold to 1, then the unflattening process will be more lax; problems of severity==1 are generally non-fatal, but may indicate that the results should be inspected, for example, to make sure there is no data loss. .SS "unflatten_seq" .IX Subsection "unflatten_seq" .Vb 6 \& Title : unflatten_seq \& Usage : @sfs = $unflattener\->unflatten_seq($seq); \& Function: turns a flat list of features into a list of holder features \& Example : \& Returns : list of Bio::SeqFeatureI objects \& Args : see below .Ve .PP partitions a list of features then arranges them in a nested tree; see above for full explanation. .PP note \- the Bio::SeqI object passed in will be modified .PP Arguments .PP .Vb 2 \& \-seq : a Bio::SeqI object; must contain Bio::SeqFeatureI objects \& (this is optional if seq has already been set) \& \& \-use_magic: if TRUE (ie non\-zero) then magic will be invoked; \& see discussion above. \& \& \-resolver_method: a CODE reference \& see the documentation above for an example of \& a subroutine that can be used to resolve hierarchies \& within groups. \& \& this is optional \- if nothing is supplied, a default \& subroutine will be used (see below) \& \& \-group_tag: a string \& [ see the group_tag() method ] \& this overrides the default group_tag which is \*(Aqgene\*(Aq .Ve .SS "unflatten_groups" .IX Subsection "unflatten_groups" .Vb 6 \& Title : unflatten_groups \& Usage : \& Function: iterates over groups, calling unflatten_group() [see below] \& Example : \& Returns : list of Bio::SeqFeatureI objects that are holders \& Args : see below .Ve .PP Arguments .PP .Vb 2 \& \-groups: list of list references; inner list is of Bio::SeqFeatureI objects \& e.g. ( [$sf1], [$sf2, $sf3, $sf4], [$sf5, ...], ...) \& \& \-resolver_method: a CODE reference \& see the documentation above for an example of \& a subroutine that can be used to resolve hierarchies \& within groups. \& \& this is optional \- a default subroutine will be used .Ve .PP \&\s-1NOTE:\s0 You should not need to call this method, unless you want fine grained control over how the unflattening process. .SS "unflatten_group" .IX Subsection "unflatten_group" .Vb 6 \& Title : unflatten_group \& Usage : \& Function: nests a group of features into a feature containment hierarchy \& Example : \& Returns : Bio::SeqFeatureI objects that holds other features \& Args : see below .Ve .PP Arguments .PP .Vb 1 \& \-group: reference to list of Bio::SeqFeatureI objects \& \& \-resolver_method: a CODE reference \& see the documentation above for an example of \& a subroutine that can be used to resolve hierarchies \& within groups \& \& this is optional \- a default subroutine will be used .Ve .PP \&\s-1NOTE:\s0 You should not need to call this method, unless you want fine grained control over how the unflattening process. .SS "feature_from_splitloc" .IX Subsection "feature_from_splitloc" .Vb 6 \& Title : feature_from_splitloc \& Usage : $unflattener\->feature_from_splitloc(\-features=>$sfs); \& Function: \& Example : \& Returns : \& Args : see below .Ve .PP At this time all this method does is generate exons for mRNA or other \s-1RNA\s0 features .PP Arguments: .PP .Vb 3 \& \-feature: a Bio::SeqFeatureI object (that conforms to Bio::FeatureHolderI) \& \-seq: a Bio::SeqI object that contains Bio::SeqFeatureI objects \& \-features: an arrayref of Bio::SeqFeatureI object .Ve .SS "infer_mRNA_from_CDS" .IX Subsection "infer_mRNA_from_CDS" .Vb 6 \& Title : infer_mRNA_from_CDS \& Usage : \& Function: \& Example : \& Returns : \& Args : .Ve .PP given a \*(L"type 1\*(R" containment hierarchy .PP .Vb 3 \& gene \& CDS \& exon .Ve .PP this will infer the uniform \*(L"type 0\*(R" containment hierarchy .PP .Vb 4 \& gene \& mRNA \& CDS \& exon .Ve .PP all the children of the \s-1CDS\s0 will be moved to the mRNA .PP a \*(L"type 2\*(R" containment hierarchy is mixed type \*(L"0\*(R" and \*(L"1\*(R" (for example, see ftp.ncbi.nih.gov/genomes/Schizosaccharomyces_pombe/) .SS "remove_types" .IX Subsection "remove_types" .Vb 6 \& Title : remove_types \& Usage : $unf\->remove_types(\-seq=>$seq, \-types=>["mRNA"]); \& Function: \& Example : \& Returns : \& Args : .Ve .PP removes features of a set type .PP useful for pre-filtering a genbank record; eg to get rid of STSs .PP also, there is no way to unflatten ftp.ncbi.nih.gov/genomes/Schizosaccharomyces_pombe/ \s-1UNLESS\s0 the bogus mRNAs in these records are removed (or changed to a different type) \- they just confuse things too much