FAST/Bio/SeqIO/flybase_chadoxml.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 44 SCAR 17.9
CC
2
Cov
0%
return_reltypename
6.0
_initialize
2.0
return_ftype_hash
2.0
CRAP 6.0
1 #
2 # BioPerl module for FAST::Bio::SeqIO::flybase_chadoxml
3 #
4 # Peili Zhang <peili@morgan.harvard.edu>
5 #
6 # You may distribute this module under the same terms as perl itself
7  
8 # POD documentation - main docs before the code
9  
10 =head1 NAME
11  
12 FAST::Bio::SeqIO::flybase_chadoxml - FlyBase variant of chadoxml with sequence output stream
13  
14 =head1 SYNOPSIS
15  
16 It is probably best not to use this object directly, but
17 rather go through the SeqIO handler system:
18  
19 $writer = FAST::Bio::SeqIO->new(-file => ">chado.xml",
20 -format => 'flybase_chadoxml');
21  
22 # assume you already have Sequence or SeqFeature objects
23 $writer->write_seq($seq_obj);
24  
25 #after writing all seqs
26 $writer->close_chadoxml();
27  
28  
29 =head1 DESCRIPTION
30  
31 This is a simple subclass of L<FAST::Bio::SeqIO::chadoxml>; please see
32 its documentation for details.
33  
34 =head1 FEEDBACK
35  
36 =head2 Mailing Lists
37  
38 User feedback is an integral part of the evolution of this and other
39 Bioperl modules. Send your comments and suggestions preferably to one
40 of the Bioperl mailing lists. Your participation is much appreciated.
41  
42 bioperl-l@bioperl.org - General discussion
43 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44  
45 =head2 Support
46  
47 Please direct usage questions or support issues to the mailing list:
48  
49 I<bioperl-l@bioperl.org>
50  
51 rather than to the module maintainer directly. Many experienced and
52 reponsive experts will be able look at the problem and quickly
53 address it. Please include a thorough description of the problem
54 with code and data examples if at all possible.
55  
56 =head2 Reporting Bugs
57  
58 Report bugs to the Bioperl bug tracking system to help us keep track
59 the bugs and their resolution.
60 Bug reports can be submitted via the web:
61  
62 https://redmine.open-bio.org/projects/bioperl/
63  
64 =head1 AUTHOR - Peili Zhang
65  
66 Email peili@morgan.harvard.edu
67  
68 =head1 APPENDIX
69  
70 The rest of the documentation details each of the object
71 methods. Internal methods are usually preceded with a _
72  
73 =cut
74  
75 package FAST::Bio::SeqIO::flybase_chadoxml;
76 use strict;
77  
78 use base 'FAST::Bio::SeqIO::chadoxml';
79  
80 sub _initialize {
81 my($self,%args) = @_;
82 $self->SUPER::_initialize(%args);
83  
84 #default for standard chado is polypeptide
85 $FAST::Bio::SeqIO::chadoxml::feattype_args2so{'CDS'} = 'protein';
86 $FAST::Bio::SeqIO::chadoxml::cv_name{'sequence'} = 'SO';
87 $FAST::Bio::SeqIO::chadoxml::cv_name{'relationship'} = 'relationship type';
88 $FAST::Bio::SeqIO::chadoxml::cv_name{'feature_property'} = 'property type';
89  
90 return;
91 }
92  
93 =head2 return_ftype_hash
94  
95 Title : return_ftype_hash
96 Usage : $obj->return_ftype_hash()
97 Function : A simple hash where returning it has be factored out of the main
98 code to allow subclasses to override it.
99 Returns : A hash that indicates what the name of the SO term is and what
100 the name of the Sequence Ontology is in the cv table.
101 Args : The string that represents the SO term.
102 Status :
103  
104 =cut
105  
106 sub return_ftype_hash {
107 my $self = shift;
108 my $ftype = shift;
109 my %ftype_hash = ( "name" => $ftype,
110 "cv_id" => {"name" => $FAST::Bio::SeqIO::chadoxml::cv_name{'sequence'} });
111 return %ftype_hash;
112 }
113  
114 =head2 return_reltypename
115  
116 Title : return_reltypename
117 Usage : $obj->return_reltypename
118 Function : Return the appropriate relationship type name depending on the
119 feature type (typically part_of, but derives_from for polypeptide).
120 Returns : A relationship type name.
121 Args : A SO type name.
122 Status :
123  
124 =cut
125  
126 sub return_reltypename {
127 my $self = shift;
128 my $sftype = shift;
129  
130 my $reltypename;
131 if ($sftype eq 'protein' || $sftype eq 'polypeptide') {
132 $reltypename = 'producedby';
133 } else {
134 $reltypename = 'partof';
135 }
136  
137 return $reltypename;
138 }
139  
140 =head2 write_seq
141  
142 Title : write_seq
143 Usage : $stream->write_seq(-seq=>$seq, -seq_so_type=>$seqSOtype,
144 -src_feature=>$srcfeature,
145 -src_feat_type=>$srcfeattype,
146 -nounflatten=>0 or 1,
147 -is_analysis=>'true' or 'false',
148 -data_source=>$datasource)
149 Function: writes the $seq object (must be seq) into chadoxml.
150 Returns : 1 for success and 0 for error
151 Args : A FAST::Bio::Seq object $seq, optional $seqSOtype, $srcfeature,
152 $srcfeattype, $nounflatten, $is_analysis and $data_source.
153  
154 Overrides FAST::Bio::SeqIO::chadoxml's write_seq method just to add an internal
155 close_chadoxml (mimics original use by FlyBase).
156  
157 =cut
158  
159 sub write_seq {
160 my ($self, @argv) = @_;
161  
162 $self->SUPER::write_seq(@argv);
163  
164 $self->close_chadoxml;
165 return 1;
166 }
167  
168  
169 1;