BioPerl

 view release on metacpan or  search on metacpan

Bio/SeqIO/chadoxml.pm  view on Meta::CPAN

use Bio::SeqIO::FTHelper;
use Bio::Species;
use Bio::Seq::SeqFactory;
use Bio::Factory::SequenceStreamI;
use Bio::SeqFeature::Generic;
use Bio::Annotation::Collection;
use Bio::Annotation::Comment;
use Bio::Annotation::Reference;
use Bio::Annotation::DBLink;
use Bio::SeqFeature::Tools::Unflattener;

#global variables
undef(my %finaldatahash); #data from Bio::Seq object stored in a hash
undef(my %datahash); #data from Bio::Seq object stored in a hash

my $chadotables = 'feature featureprop feature_relationship featureloc feature_cvterm cvterm cv feature_pub pub pub_dbxref pub_author author pub_relationship pubprop feature_dbxref dbxref db synonym feature_synonym';

my %fkey = (
    "cvterm.cv_id"          => "cv",
        "cvterm.dbxref_id"              => "dbxref",
    "dbxref.db_id"          => "db",
    "feature.type_id"       => "cvterm",
    "feature.organism_id"       => "organism",
    "feature.dbxref_id"         => "dbxref",
    "featureprop.type_id"       => "cvterm",
    "feature_pub.pub_id"        => "pub",
    "feature_cvterm.cvterm_id"  => "cvterm",
    "feature_cvterm.pub_id"     => "pub",
        "feature_cvterm.feature_id"     => "feature",
    "feature_dbxref.dbxref_id"  => "dbxref",
    "feature_relationship.object_id"    => "feature",
    "feature_relationship.subject_id"   => "feature",
    "feature_relationship.type_id"  => "cvterm",
    "featureloc.srcfeature_id"  => "feature",
    "pub.type_id"           => "cvterm",
    "pub_dbxref.dbxref_id"      => "dbxref",
    "pub_author.author_id"      => "author",
    "pub_relationship.obj_pub_id"   => "pub",
    "pub_relationship.subj_pub_id"  => "pub",
    "pub_relationship.type_id"  => "cvterm",
    "pubprop.type_id"       => "cvterm",
        "feature_synonym.feature_id"    => "feature",
        "feature_synonym.synonym_id"    => "synonym",
        "feature_synonym.pub_id"        => "pub",
        "synonym.type_id"               => "cvterm",
);

my %cv_name = (
        'relationship'                  => 'relationship',
        'sequence'                      => 'sequence',
        'feature_property'              => 'feature_property',
);

my %feattype_args2so = (
    "aberr"             => "aberration_junction",
#   "conflict"          => "sequence_difference",
#   "polyA_signal"          => "polyA_signal_sequence",
    "variation"         => "sequence_variant",
    "mutation1"         => "point_mutation",        #for single-base mutation
    "mutation2"         => "sequence_variant",      #for multi-base mutation
    "rescue"            => "rescue_fragment",
#   "rfrag"             => "restriction_fragment",
    "protein_bind"          => "protein_binding_site",
    "misc_feature"          => "region",
#   "prim_transcript"       => "primary_transcript",
    "CDS"               => "polypeptide",
    "reg_element"           => "regulatory_region",
    "seq_variant"           => "sequence_variant",
    "mat_peptide"           => "mature_peptide",
    "sig_peptide"           => "signal_peptide",
);

undef(my %organism);

use base qw(Bio::SeqIO);

sub _initialize {

    my($self,%args) = @_;

    $self->SUPER::_initialize(%args);
    unless( defined $self->sequence_factory ) {
        $self->sequence_factory(Bio::Seq::SeqFactory->new
                                (-verbose => $self->verbose(),
                                 -type => 'Bio::Seq::RichSeq'));
    }
    #optional arguments that can be passed in
    $self->suppress_residues($args{'-suppress_residues'})
        if defined $args{'-suppress_residues'};

    $self->allow_residues($args{'-allow_residues'})
        if defined $args{'-allow_residues'};
    return;
}

=head2 write_seq

 Title   : write_seq
 Usage   : $stream->write_seq(-seq=>$seq, -seq_so_type=>$seqSOtype,
                  -src_feature=>$srcfeature,
                  -src_feat_type=>$srcfeattype,
                  -nounflatten=>0 or 1,
                  -is_analysis=>'true' or 'false',
                  -data_source=>$datasource)
 Function: writes the $seq object (must be seq) into chadoxml.
 Returns : 1 for success and 0 for error
 Args     : A Bio::Seq object $seq, optional $seqSOtype, $srcfeature,
            $srcfeattype, $nounflatten, $is_analysis and $data_source.

When $srcfeature (a string, the uniquename of the source feature) is given, the
location and strand information of the top-level feature against the source
feature will be derived from the sequence feature called 'source' of the $seq
object, a featureloc record is generated for the top -level feature on
$srcfeature. when $srcfeature is given, $srcfeattype must also be present. All
feature coordinates in $seq should be against $srcfeature. $seqSOtype is the
optional SO term to use as the type of the top-level feature. For example, a
GenBank data file for a Drosophila melanogaster genome scaffold has the molecule
type of "DNA", when converting to chadoxml, a $seqSOtype argument of
"golden_path_region" can be supplied to save the scaffold as a feature of type
"golden_path_region" in chadoxml, instead of "DNA". a feature with primary tag
of 'source' must be present in the sequence feature list of $seq, to describe the
whole sequence record.



( run in 1.194 second using v1.01-cache-2.11-cpan-364913b4093 )