annotate cpt_psm_comparison_table/lib/CPT/Bio/DataSource/Chado.pm @ 0:b8b8b52904a5 draft

Uploaded
author cpt
date Tue, 05 Jul 2022 05:42:59 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
1 package CPT::Bio::DataSource::Chado;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
2 no warnings;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
3 use Moose;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
4 with 'CPT::Bio::DataSource';
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
5
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
6 has 'host' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
7 has 'pass' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
8 has 'user' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
9 has 'name' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
10 has 'port' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
11
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
12 has 'landmark' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
13 has 'organism' => ( is => 'rw', isa => 'Str' );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
14
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
15
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
16 sub getSeqIO {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
17 my ($self) = @_;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
18 require CPT::Chado::GMOD_Conf;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
19
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
20 my $db = Bio::DB::Das::Chado->new(
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
21 -dsn => sprintf( 'dbi:Pg:dbname=%s;host=%s;port=%s', $self->name(), $self->host(), $self->port() ),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
22 -user => $self->user(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
23 -pass => $self->pass(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
24 -organism => $self->organism(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
25 -inferCDS => 1,
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
26
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
27 );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
28
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
29 # Get a list of "segments". Essentially (seqlen IS NOT NULL)
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
30 my @segments = $db->segment( -name => $self->{'landmark'} );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
31
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
32 # TODO: Need to have a fallback method
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
33 # Should only produce ONE since we specify landmark exactly
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
34 foreach my $segment (@segments) {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
35 my $stream = $segment->get_feature_stream();
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
36 use Bio::Seq;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
37 my $seq_obj = Bio::Seq->new(
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
38 -seq => $segment->seq->seq(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
39 -display_id => $segment->id()
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
40 );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
41 use Bio::SeqFeature::Generic;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
42 while ( my $feat = $stream->next_seq ) {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
43
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
44 # In an IDEAL world we'd just do $seq_obj->add_SeqFeature($feat);
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
45 #
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
46 # HOWEVER.
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
47 #
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
48 # ------------- EXCEPTION: Bio::Root::NotImplemented -------------
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
49 # MSG: Abstract method "Bio::DB::Das::Chado::Segment::Feature::attach_seq" is not implemented by package Bio::DB::Das::Chado::Segment::Feature.
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
50 # This is not your fault - author of Bio::DB::Das::Chado::Segment::Feature should be blamed!
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
51 # STACK: Error::throw
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
52 # STACK: Bio::Root::Root::throw /usr/local/share/perl/5.14.2/Bio/Root/Root.pm:472
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
53 # STACK: Bio::Root::RootI::throw_not_implemented /usr/local/share/perl/5.14.2/Bio/Root/RootI.pm:748
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
54 # STACK: Bio::DB::Das::Chado::Segment::Feature::attach_seq /usr/local/share/perl/5.14.2/Bio/DB/Das/Chado/Segment/Feature.pm:374
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
55 # STACK: Bio::Seq::add_SeqFeature /usr/local/share/perl/5.14.2/Bio/Seq.pm:1148
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
56 # STACK: chado_export.pl:59
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
57 # ----------------------------------------------------------------
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
58
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
59 # BUT WE CAN'T. >_> rageface.tiff
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
60
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
61 my %keys;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
62 foreach my $tag ( $feat->get_all_tags() ) {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
63 my @values = $feat->get_tag_values($tag);
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
64 if ( $tag eq 'Note' ) {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
65 $tag = 'note';
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
66 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
67 if ( $tag eq 'Dbxref' ) {
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
68 $tag = 'db_xref';
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
69
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
70 #@values = map { if($_ ne 'GFF_source:Genbank'){ $_ } } @values;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
71 @values = grep !/GFF_source:Genbank/, @values;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
72 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
73 $keys{$tag} = \@values;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
74 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
75
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
76 #print $feat->gff_string(),"\n";
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
77 my $new_feat = new Bio::SeqFeature::Generic(
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
78 -start => $feat->start(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
79 -end => $feat->end(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
80 -strand => $feat->strand(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
81 -primary_tag => $feat->primary_tag(),
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
82 -tag => \%keys,
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
83 );
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
84 $seq_obj->add_SeqFeature($new_feat);
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
85 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
86
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
87 return $seq_obj;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
88 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
89
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
90 }
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
91
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
92 no Moose;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
93 1;
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
94
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
95 __END__
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
96
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
97 =pod
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
98
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
99 =encoding UTF-8
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
100
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
101 =head1 NAME
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
102
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
103 CPT::Bio::DataSource::Chado
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
104
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
105 =head1 VERSION
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
106
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
107 version 1.99.4
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
108
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
109 =head2 getSeqIO
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
110
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
111 supposed to get a seqIO object from a chado DB. not fully implemented
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
112
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
113 =head1 AUTHOR
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
114
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
115 Eric Rasche <rasche.eric@yandex.ru>
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
116
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
117 =head1 COPYRIGHT AND LICENSE
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
118
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
119 This software is Copyright (c) 2014 by Eric Rasche.
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
120
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
121 This is free software, licensed under:
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
122
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
123 The GNU General Public License, Version 3, June 2007
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
124
b8b8b52904a5 Uploaded
cpt
parents:
diff changeset
125 =cut