sync last bits with main trunk
[bioperl-live.git] / Bio / SeqIO / flybase_chadoxml.pm
blob7c1da88bf65b3bb7284175b63f23458285a0e8dd
1 # $Id$
3 # BioPerl module for Bio::SeqIO::flybase_chadoxml
5 # Peili Zhang <peili@morgan.harvard.edu>
7 # You may distribute this module under the same terms as perl itself
9 # POD documentation - main docs before the code
11 =head1 NAME
13 Bio::SeqIO::flybase_chadoxml - FlyBase variant of chadoxml with sequence output stream
15 =head1 SYNOPSIS
17 It is probably best not to use this object directly, but
18 rather go through the SeqIO handler system:
20 $writer = Bio::SeqIO->new(-file => ">chado.xml",
21 -format => 'flybase_chadoxml');
23 # assume you already have Sequence or SeqFeature objects
24 $writer->write_seq($seq_obj);
26 #after writing all seqs
27 $writer->close_chadoxml();
30 =head1 DESCRIPTION
32 This is a simple subclass of L<Bio::SeqIO::chadoxml>; please see
33 its documentation for details.
35 =head1 FEEDBACK
37 =head2 Mailing Lists
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to one
41 of the Bioperl mailing lists. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 =head2 Support
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
57 =head2 Reporting Bugs
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 the bugs and their resolution.
61 Bug reports can be submitted via the web:
63 http://bugzilla.bioperl.org
65 =head1 AUTHOR - Peili Zhang
67 Email peili@morgan.harvard.edu
69 =head1 APPENDIX
71 The rest of the documentation details each of the object
72 methods. Internal methods are usually preceded with a _
74 =cut
76 package Bio::SeqIO::flybase_chadoxml;
77 use strict;
79 use base 'Bio::SeqIO::chadoxml';
81 sub _initialize {
82 my($self,%args) = @_;
83 $self->SUPER::_initialize(%args);
85 #default for standard chado is polypeptide
86 $Bio::SeqIO::chadoxml::feattype_args2so{'CDS'} = 'protein';
87 $Bio::SeqIO::chadoxml::cv_name{'sequence'} = 'SO';
88 $Bio::SeqIO::chadoxml::cv_name{'relationship'} = 'relationship type';
89 $Bio::SeqIO::chadoxml::cv_name{'feature_property'} = 'property type';
91 return;
95 =head2 return_ftype_hash
97 =over
99 =item Usage
101 $obj->return_ftype_hash()
103 =item Function
105 A simple hash where returning it has be factored out of the main
106 code to allow subclasses to override it.
108 =item Returns
110 A hash that indicates what the name of the SO term is and what
111 the name of the Sequence Ontology is in the cv table.
113 =item Arguments
115 The string that represents the SO term.
117 =back
119 =cut
121 sub return_ftype_hash {
122 my $self = shift;
123 my $ftype = shift;
124 my %ftype_hash = ( "name" => $ftype,
125 "cv_id" => {"name" => $Bio::SeqIO::chadoxml::cv_name{'sequence'} });
126 return %ftype_hash;
129 =head2 return_reltypename
131 =over
133 =item Usage
135 $obj->return_reltypename()
137 =item Function
139 Return the appropriate relationship type name depending on the
140 feature type (typically partof, but producedby for proteins).
142 =item Returns
144 A relationship type name.
146 =item Arguments
148 A SO type name.
150 =back
152 =cut
154 sub return_reltypename {
155 my $self = shift;
156 my $sftype = shift;
158 my $reltypename;
159 if ($sftype eq 'protein' || $sftype eq 'polypeptide') {
160 $reltypename = 'producedby';
161 } else {
162 $reltypename = 'partof';
165 return $reltypename;
168 =head2 write_seq
170 =over
172 =item Usage
174 $obj->write_seq()
176 =item Function
178 Overrides Bio::SeqIO::chadoxml's write_seq method just
179 to add an internal close_chadoxml (mimics original use
180 by FlyBase).
182 =item Returns
184 =item Arguments
186 =back
188 =cut
190 sub write_seq {
191 my ($self, @argv) = @_;
193 $self->SUPER::write_seq(@argv);
195 $self->close_chadoxml;
196 return 1;