3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 my $dfa = $db->get_DitagFeatureAdaptor;
40 foreach my $ditagFeature (@$ditagFeatures) {
41 print $ditagFeature->ditag_id .
" "
42 . $ditagFeature->slice .
" "
43 . $ditagFeature->start .
"-"
44 . $ditagFeature->end .
" "
45 . $ditagFeature->strand;
57 package Bio::EnsEMBL::Map::DBSQL::DitagFeatureAdaptor;
73 Example : @all_tags = @{$ditagfeature_adaptor->fetch_all};
74 Description: Retrieves all ditagFeatures from the database;
75 Usually not a good idea, use fetch_all_by_Slice instead.
85 my $sth = $self->prepare(
"SELECT df.ditag_feature_id, df.ditag_id, df.seq_region_id,
86 df.seq_region_start, df.seq_region_end, df.seq_region_strand,
87 df.analysis_id, df.hit_start, df.hit_end, df.hit_strand,
88 df.cigar_line, df.ditag_side, df.ditag_pair_id, d.tag_count
89 FROM ditag_feature df, ditag d
90 WHERE df.ditag_id=d.ditag_id" );
93 my $result = $self->_fetch($sth);
101 Arg [1] : ditagFeature dbID
102 Example : @my_tags = @{$ditagfeature_adaptor->fetch_by_dbID($my_id)};
103 Description: Retrieves a ditagFeature from the database.
111 my ($self, $dbid) = @_;
113 my $sth = $self->prepare(
"SELECT df.ditag_feature_id, df.ditag_id, df.seq_region_id,
114 df.seq_region_start, df.seq_region_end, df.seq_region_strand,
115 df.analysis_id, df.hit_start, df.hit_end, df.hit_strand,
116 df.cigar_line, df.ditag_side, df.ditag_pair_id, d.tag_count
117 FROM ditag_feature df, ditag d
118 WHERE df.ditag_id=d.ditag_id AND df.ditag_feature_id = ?" );
119 $sth->execute($dbid);
121 my $result = $self->_fetch($sth);
127 =head2 fetch_all_by_ditagID
130 Arg [2] : (optional) ditag-pair dbID
131 Arg [3] : (optional) analysis ID
132 Example : @my_tags = @{$ditagfeature_adaptor->fetch_all_by_ditag_id($my_id)};
133 Description: Retrieves all ditagFeatures from the database linking to a specific ditag-
id
140 sub fetch_all_by_ditagID {
141 my ($self, $ditag_id, $ditag_pair_id, $analysis_id) = @_;
144 my $sql =
"SELECT df.ditag_feature_id, df.ditag_id, df.seq_region_id,
145 df.seq_region_start, df.seq_region_end, df.seq_region_strand,
146 df.analysis_id, df.hit_start, df.hit_end, df.hit_strand,
147 df.cigar_line, df.ditag_side, df.ditag_pair_id, d.tag_count
148 FROM ditag_feature df, ditag d
149 WHERE df.ditag_id=d.ditag_id AND df.ditag_id = ? ";
151 $sql .=
"AND df.ditag_pair_id = ? ";
152 $arg .=
", $ditag_pair_id";
155 $sql .=
"AND df.analysis_id = ? ";
156 $arg .=
", $analysis_id";
158 $sql .=
"ORDER BY df.ditag_pair_id";
159 my $sth = $self->prepare($sql);
160 $sth->execute(split(
",",$arg));
162 my $result = $self->_fetch($sth);
168 =head2 fetch_all_by_type
171 Example : @my_tags = @{$ditagfeature_adaptor->fetch_all_by_type($type)};
172 Description: Retrieves all ditagFeatures from the database linking to a specific ditag-type
179 sub fetch_all_by_type {
180 my ($self, $ditag_type) = @_;
182 my $sth = $self->prepare(
"SELECT df.ditag_feature_id, df.ditag_id, df.seq_region_id,
183 df.seq_region_start, df.seq_region_end, df.seq_region_strand,
184 df.analysis_id, df.hit_start, df.hit_end, df.hit_strand,
185 df.cigar_line, df.ditag_side, df.ditag_pair_id, d.tag_count
186 FROM ditag_feature df, ditag d
187 WHERE df.ditag_id=d.ditag_id AND d.type = ?
188 ORDER BY df.ditag_id, df.ditag_pair_id" );
189 $sth->execute($ditag_type);
191 my $result = $self->_fetch($sth);
197 =head2 fetch_all_by_Slice
200 Arg [2] : (optional) ditag type name (specific library) or an aray ref with multiple type names
201 Arg [3] : (optional) analysis logic_name
202 Example : $tags = $ditagfeature_adaptor->fetch_all_by_Slice($slice,
"SME005");
203 Description: Retrieves ditagFeatures from the database overlapping a specific region
204 and (optional) of a specific ditag type or analysis.
205 Start & end locations are returned in slice coordinates, now.
206 Returntype : listref of Bio::EnsEMBL::Map::DitagFeatures
212 sub fetch_all_by_Slice {
213 my ($self, $slice, $tagtype, $logic_name) = @_;
218 if(!ref($slice) || !$slice->isa(
"Bio::EnsEMBL::Slice")) {
219 throw(
"Bio::EnsEMBL::Slice argument expected not $slice.");
222 #get affected ditag_feature_ids
223 my $sql =
"SELECT df.ditag_feature_id, df.ditag_id, df.seq_region_id, df.seq_region_start,
224 df.seq_region_end, df.seq_region_strand, df.analysis_id, df.hit_start, df.hit_end,
225 df.hit_strand, df.cigar_line, df.ditag_side, df.ditag_pair_id,
227 FROM ditag_feature df, ditag d
228 WHERE df.ditag_id=d.ditag_id";
232 if(ref $tagtype eq
'ARRAY'){
234 foreach my $arraytype (@$tagtype){ push @arraytype_mod,
'"'.$arraytype.
'"' }
235 $tagtypes = join(
", ", @arraytype_mod);
238 $tagtypes =
'"'.$tagtype.
'"';
240 $sql .=
" AND d.type IN(".$tagtypes.
")";
243 my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name($logic_name);
247 $sql .=
" AND df.analysis_id = ".$analysis->dbID();
249 $sql .=
" AND df.seq_region_id = ".$slice->get_seq_region_id.
250 " AND df.seq_region_start <= ".$slice->end.
251 " AND df.seq_region_end >= ".$slice->start;
253 my $sth = $self->prepare($sql);
256 my $result = $self->_fetch($sth, $slice);
257 push(@result, @$result);
263 =head2 fetch_pairs_by_Slice
266 Arg [2] : (optional) ditag type (specific library)
267 Arg [3] : (optional) analysis logic_name
268 Example : my $ditagfeatures = $dfa->fetch_pairs_by_Slice($slice);
269 foreach my $ditagfeature (@$ditagfeatures){
270 $minstart = $$ditagfeature2{
'start'};
271 $maxend = $$ditagfeature2{
'end'};
272 $bothstrand = $$ditagfeature2{
'strand'};
273 $tag_count = $$ditagfeature2{
'tag_count'};
274 print
"$minstart, $maxend, $bothstrand, $tag_count\n";
276 Description: Retrieves ditagFeature information in pairs from the database overlapping a specific region
277 and (optional) of a specific ditag type or analysis. The absotute start and end points are
279 Slices should be SMALL!
280 Returntype : array ref with hash ref of artifical DitagFeature
object
286 sub fetch_pairs_by_Slice {
287 my ($self, $slice, $tagtype, $logic_name) = @_;
288 my ($tag_id, $pair_id, $seq_region_id, $start, $end, $strand, $analysis_id, $tag_count);
291 my $sql =
"SELECT df.ditag_id, df.ditag_pair_id, df.seq_region_id, MIN(df.seq_region_start), ".
292 "MAX(df.seq_region_end), df.seq_region_strand, df.analysis_id, d.tag_count ".
293 "FROM ditag_feature df, ditag d ".
294 "WHERE df.ditag_id=d.ditag_id ";
296 $sql .=
"AND d.type = \"".$tagtype.
"\"";
298 $sql .=
" AND df.seq_region_id = ".$slice->get_seq_region_id.
299 " AND df.seq_region_start <= ".$slice->end.
300 " AND df.seq_region_end >= ".$slice->start;
302 my $analysis = $self->db->get_AnalysisAdaptor->fetch_by_logic_name($logic_name);
306 $sql .=
" AND df.analysis_id = ".$analysis->dbID();
308 $sql .=
" GROUP BY df.ditag_id, df.ditag_pair_id;";
309 my $sth = $self->prepare($sql);
311 $sth->bind_columns( \$tag_id, \$pair_id, \$seq_region_id, \$start, \$end, \$strand, \$analysis_id ,\$tag_count);
312 while ( $sth->fetch ) {
313 # convert into relative slice coordinates
314 my $seq_region_len = $slice->seq_region_length();
316 if ($slice->strand == 1) { # Positive strand
317 $start = $start - $slice->start + 1;
318 $end = $end - $slice->start + 1;
320 if ($slice->is_circular()) { # Handle circular chromosomes
321 if ($start > $end) { # Looking at a feature overlapping the chromsome origin
322 if ($end > $slice->start) {
323 # Looking at the region in the beginning of the chromosome
324 $start -= $seq_region_len;
328 $end += $seq_region_len;
331 if ($slice->start > $slice->end && $end < 0) {
332 # Looking at the region overlapping the chromosome origin and
333 # a feature which is at the beginning of the chromosome
334 $start += $seq_region_len;
335 $end += $seq_region_len;
338 } # end
if ($dest_slice->is_circular...)
340 }
else { # Negative strand
341 my ($seq_region_start, $seq_region_end) = ($start, $end);
342 $start = $slice->end - $seq_region_end + 1;
343 $end = $slice->end - $seq_region_start + 1;
345 if ($slice->is_circular()) {
346 if ($slice->start > $slice->end) { # slice spans origin or replication
347 if ($seq_region_start >= $slice->start) {
348 $end += $seq_region_len;
349 $start += $seq_region_len
350 if $seq_region_end > $slice->start;
352 } elsif ($seq_region_start <= $slice->end) {
354 } elsif ($seq_region_end >= $slice->start) {
355 $start += $seq_region_len;
356 $end += $seq_region_len;
358 } elsif ($seq_region_end <= $slice->end) {
359 $end += $seq_region_len
361 } elsif ($seq_region_start > $seq_region_end) {
362 $end += $seq_region_len;
366 if ($seq_region_start <= $slice->end and $seq_region_end >= $slice->start) {
368 } elsif ($seq_region_start > $seq_region_end) {
369 if ($seq_region_start <= $slice->end) {
370 $start -= $seq_region_len;
371 } elsif ($seq_region_end >= $slice->start) {
372 $end += $seq_region_len;
381 my %ditag_feature_pair = (
384 region => $seq_region_id,
388 analysis => $analysis_id,
389 tag_count => $tag_count
391 push(@result, \%ditag_feature_pair);
400 Arg [1] : statement handler
401 Arg [2] : (optional) target-slice
for the feature
402 Description:
generic sql-fetch
function for the DitagFeature fetch methods
403 Returntype : listref of Bio::EnsEMBL::Map::DitagFeatures
410 my ($self, $sth, $dest_slice) = @_;
412 my ( $tag_id, $mothertag_id, $seqreg, $seqstart, $seqend, $strand, $analysis_id, $hit_start,
413 $hit_end, $hit_strand, $cigar_line, $ditag_side, $ditag_pair_id, $tag_count );
414 $sth->bind_columns( \$tag_id, \$mothertag_id, \$seqreg,
415 \$seqstart, \$seqend, \$strand,
416 \$analysis_id, \$hit_start, \$hit_end,
417 \$hit_strand, \$cigar_line, \$ditag_side,
418 \$ditag_pair_id, \$tag_count );
421 my $dest_slice_start;
423 my $dest_slice_strand;
425 $dest_slice_start = $dest_slice->start();
426 $dest_slice_end = $dest_slice->end();
427 $dest_slice_strand = $dest_slice->strand();
430 while ( $sth->fetch ) {
431 my $analysis_obj = $self->db->get_AnalysisAdaptor->fetch_by_dbID($analysis_id);
432 my $slice = $self->db->get_SliceAdaptor->fetch_by_seq_region_id($seqreg);
435 if($dest_slice_start != 1 || $dest_slice_strand != 1) {
436 if($dest_slice_strand == 1) {
437 $seqstart = $seqstart - $dest_slice_start + 1;
438 $seqend = $seqend - $dest_slice_start + 1;
440 my $tmp_seq_region_start = $seqstart;
441 $seqstart = $dest_slice_end - $seqend + 1;
442 $seqend = $dest_slice_end - $tmp_seq_region_start + 1;
447 my $seq_region_len = $dest_slice->seq_region_length();
449 if ($dest_slice_strand == 1) { # Positive strand
450 $seqstart = $seqstart - $dest_slice_start + 1;
451 $seqend = $seqend - $dest_slice_start + 1;
453 if ($dest_slice->is_circular()) { # Handle cicular chromosomes
454 if ($seqstart > $seqend) { # Looking at a feature overlapping the chromsome origin
455 if ($seqend > $dest_slice_start) {
456 # Looking at the region in the beginning of the chromosome.
457 $seqstart -= $seq_region_len;
461 $seqend += $seq_region_len;
464 if ($dest_slice_start > $dest_slice_end && $seqend < 0) {
465 # Looking at the region overlapping the chromosome origin and
466 # a feature which is at the beginning of the chromosome.
467 $seqstart += $seq_region_len;
468 $seqend += $seq_region_len;
472 }
else { # Negative strand
473 my $start = $dest_slice_end - $seqend + 1;
474 my $end = $dest_slice_end - $seqstart + 1;
476 if ($dest_slice->is_circular()) {
477 if ($dest_slice_start > $dest_slice_end) {
478 # slice spans origin or replication
479 if ($seqstart >= $dest_slice_start) {
480 $end += $seq_region_len;
481 $start += $seq_region_len
482 if $seqend > $dest_slice_start;
484 } elsif ($seqstart <= $dest_slice_end) {
486 } elsif ($seqend >= $dest_slice_start) {
487 $start += $seq_region_len;
488 $end += $seq_region_len;
489 } elsif ($seqend <= $dest_slice_end) {
490 $end += $seq_region_len
492 } elsif ($seqstart > $seqend) {
493 $end += $seq_region_len;
496 if ($seqstart <= $dest_slice_end and $seqend >= $dest_slice_start) {
498 } elsif ($seqstart > $seqend) {
499 if ($seqstart <= $dest_slice_end) {
500 $start -= $seq_region_len;
501 } elsif ($seqend >= $dest_slice_start) {
502 $end += $seq_region_len;
513 $slice = $dest_slice;
516 push @ditag_features,
522 -analysis => $analysis_obj,
523 -hit_start => $hit_start,
524 -hit_end => $hit_end,
525 -hit_strand => $hit_strand,
526 -ditag_id => $mothertag_id,
527 -cigar_line => $cigar_line,
528 -ditag_side => $ditag_side,
529 -ditag_pair_id => $ditag_pair_id,
531 -tag_count => $tag_count,
536 return \@ditag_features;
542 Arg [1] : dbID of DitagFeature
543 Example : $ditagfeature_adaptor->get_sequence($ditagFeature->dbID)
544 Description: get the part of the sequence of a ditag,
545 that is actully aligned to the genome.
547 Exceptions : thrown
if not all data needed
for storing is populated in the
555 my ($self, $dbID) = @_;
557 my $sequence = undef;
558 my $db = $self->db() or
throw "Couldn t get database connection.";
559 my $sql =
"SELECT d.sequence, df.hit_start, df.hit_end, df.hit_strand ".
560 "FROM ditag d, ditag_feature df ".
561 "WHERE df.ditag_id=d.ditag_id and df.ditag_feature_id = ?";
562 my $sth = $db->dbc->prepare($sql);
563 $sth->execute( $dbID );
564 my ($seq, $start, $end, $strand) = $sth->fetchrow_array();
565 if($seq and $start and $end and $strand){
566 $sequence = substr($seq, ($start-1), ($end-$strand));
568 $sequence =~ tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/;
579 Example : $ditagfeature_adaptor->store(@ditag_features);
580 Description: Stores a single ditagFeature or
581 a list of ditagFeatures in
this database.
583 Exceptions : thrown
if not all data needed
for storing is populated in the
591 my ( $self, $ditag_features ) = @_;
593 if ( ref $ditag_features eq
'ARRAY' ) {
594 if ( scalar(@$ditag_features) == 0 ) {
595 throw(
"Must call store with ditag_feature or list ref of ditags_features" );
597 } elsif ($ditag_features) {
599 push @ditag_features, $ditag_features;
600 $ditag_features = \@ditag_features;
602 throw(
"Must call store with ditag_feature or list ref of ditag_features." );
605 my $db = $self->db() or
throw "Couldn t get database connection.";
607 my $sth1 = $self->prepare(
"INSERT INTO ditag_feature( ditag_id, seq_region_id, seq_region_start,
608 seq_region_end, seq_region_strand, analysis_id, hit_start, hit_end,
609 hit_strand, cigar_line, ditag_side, ditag_pair_id )
610 VALUES( ?,?,?,?,?,?,?,?,?,?,?,? )" );
611 my $sth2 = $self->prepare(
"INSERT INTO ditag_feature( ditag_feature_ID, ditag_id, seq_region_id,
612 seq_region_start, seq_region_end, seq_region_strand, analysis_id, hit_start,
613 hit_end, hit_strand, cigar_line, ditag_side, ditag_pair_id )
614 VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,? )" );
615 # my $sth3 = $self->prepare( "SELECT COUNT(*) FROM ditag_feature
616 # WHERE ditag_id = ?" );
619 foreach my $ditag_feature (@$ditag_features) {
621 if ( !ref $ditag_feature || !$ditag_feature->isa(
"Bio::EnsEMBL::Map::DitagFeature") ) {
622 throw(
"Object must be an Ensembl DitagFeature, "
623 .
"not a " . ref($ditag_feature) );
625 if ( $ditag_feature->is_stored($db) ) {
626 warning(
"DitagFeature " . $ditag_feature->dbID .
627 " is already stored in this database,".
628 " maybe you need to use the update() method?" );
631 if(!$ditag_feature->ditag_id or !($self->db->get_DitagAdaptor->fetch_by_dbID($ditag_feature->ditag_id))){
632 throw(
"DitagFeature must be supplied with the id of a corresponding Ditag object.");
634 if(!$ditag_feature->ditag or !$ditag_feature->ditag->isa(
"Bio::EnsEMBL::Map::Ditag")){
635 throw(
"DitagFeature must be linked to a valid Ditag object.");
639 # #check if more than x tags with this ditag id exist
640 # $sth3->execute( $ditag_feature->ditag_id );
641 # my ($num) = $sth3->fetchrow_array();
642 # if ( ($num) and ($num > 1) ) {
643 # warning( "There are already at least 2 DitagFeatures relating to Ditag ".
644 # $ditag->ditag_id." stored in this database." );
646 # warning( "not storing" );
651 if ( $ditag_feature->dbID ) {
652 $sth2->bind_param( 1, $ditag_feature->dbID, SQL_INTEGER );
653 $sth2->bind_param( 2, $ditag_feature->ditag_id, SQL_INTEGER );
654 $sth2->bind_param( 3, ($ditag_feature->slice->get_seq_region_id), SQL_INTEGER );
655 $sth2->bind_param( 4, $ditag_feature->start, SQL_INTEGER );
656 $sth2->bind_param( 5, $ditag_feature->end, SQL_INTEGER );
657 $sth2->bind_param( 6, $ditag_feature->strand, SQL_VARCHAR );
658 $sth2->bind_param( 7, $ditag_feature->analysis->dbID, SQL_INTEGER );
659 $sth2->bind_param( 8, $ditag_feature->hit_start, SQL_INTEGER );
660 $sth2->bind_param( 9, $ditag_feature->hit_end, SQL_INTEGER );
661 $sth2->bind_param( 10, $ditag_feature->hit_strand, SQL_VARCHAR );
662 $sth2->bind_param( 11, $ditag_feature->cigar_line, SQL_VARCHAR );
663 $sth2->bind_param( 12, $ditag_feature->ditag_side, SQL_VARCHAR );
664 $sth2->bind_param( 13, $ditag_feature->ditag_pair_id, SQL_VARCHAR );
668 $sth1->bind_param( 1, $ditag_feature->ditag_id, SQL_INTEGER );
669 $sth1->bind_param( 2, ($ditag_feature->slice->get_seq_region_id), SQL_INTEGER );
670 $sth1->bind_param( 3, $ditag_feature->start, SQL_INTEGER );
671 $sth1->bind_param( 4, $ditag_feature->end, SQL_INTEGER );
672 $sth1->bind_param( 5, $ditag_feature->strand, SQL_VARCHAR );
673 $sth1->bind_param( 6, $ditag_feature->analysis->dbID, SQL_INTEGER );
674 $sth1->bind_param( 7, $ditag_feature->hit_start, SQL_INTEGER );
675 $sth1->bind_param( 8, $ditag_feature->hit_end, SQL_INTEGER );
676 $sth1->bind_param( 9, $ditag_feature->hit_strand, SQL_VARCHAR );
677 $sth1->bind_param( 10, $ditag_feature->cigar_line, SQL_VARCHAR );
678 $sth1->bind_param( 11, $ditag_feature->ditag_side, SQL_VARCHAR );
679 $sth1->bind_param( 12, $ditag_feature->ditag_pair_id, SQL_VARCHAR );
681 my $dbID = $self->last_insert_id(
'ditag_feature_id', undef,
'ditag_feature');
682 $ditag_feature->dbID($dbID);
683 $ditag_feature->adaptor($self);
692 Arg [1] : (Array ref of) Bio::EnsEMBL::Map::DitagFeatures
693 Arg [2] :
bool have_dbIDs
694 Example : $ditagfeature_adaptor->batch_store(\@ditag_features);
695 Description: Stores a list of ditagFeatures in
this database.
696 DitagFeatures are expected to have no dbID yet unless flag
"have_dbIDs" is
true.
697 They are inserted in one combined INSERT
for better performance.
699 Exceptions : thrown
if not all data needed
for storing is given
for the
707 my ( $self, $ditag_features, $have_dbIDs ) = @_;
709 my @good_ditag_features;
713 if ( ref $ditag_features eq
'ARRAY' ) {
714 if ( scalar(@$ditag_features) == 0 ) {
715 throw(
"Must call store with ditag_feature or list ref of ditag_features." );
717 } elsif ($ditag_features) {
719 push @ditag_features, $ditag_features;
720 $ditag_features = \@ditag_features;
722 throw(
"Must call store with ditag_feature or list ref of ditag_features." );
725 my $db = $self->db() or
throw "Couldn t get database connection.";
727 #check whether it s a DitagFeature object and is not stored already
728 foreach my $ditag_feature (@$ditag_features) {
730 if ( !ref $ditag_feature || !$ditag_feature->isa(
"Bio::EnsEMBL::Map::DitagFeature") ) {
731 throw(
"Object must be an Ensembl DitagFeature, "
732 .
"not a " . ref($ditag_feature) );
734 if(!$ditag_feature->ditag_id or !($self->db->get_DitagAdaptor->fetch_by_dbID($ditag_feature->ditag_id))){
735 throw(
"DitagFeature must be supplied with the id of a corresponding Ditag object.");
738 if(!$ditag_feature->ditag or !$ditag_feature->ditag->isa(
"Bio::EnsEMBL::Map::Ditag")){
739 throw(
"DitagFeature must be linked to a valid Ditag object.");
741 if ( $ditag_feature->is_stored($db) ) {
742 warning(
"DitagFeature " . $ditag_feature->dbID
743 .
" is already stored in this database." );
746 push(@good_ditag_features, $ditag_feature);
748 $ditag_features = undef;
752 $sql =
"INSERT INTO ditag_feature ( ditag_feature_id, ditag_id, seq_region_id, seq_region_start, ".
753 "seq_region_end, seq_region_strand, analysis_id, hit_start, hit_end, ".
754 "hit_strand, cigar_line, ditag_side, ditag_pair_id ) VALUES ";
755 foreach my $ditag_feature (@good_ditag_features) {
757 if($inserts){ $sqladd =
", " }
758 $sqladd .=
"(". $ditag_feature->ditag_feature_id.
", ".$ditag_feature->ditag_id.
", ".
759 ($ditag_feature->slice->get_seq_region_id).
", ". $ditag_feature->start.
", ".
760 $ditag_feature->end.
", '".$ditag_feature->strand.
"', ".$ditag_feature->analysis->dbID.
", ".
761 $ditag_feature->hit_start.
", ".$ditag_feature->hit_end.
", '".$ditag_feature->hit_strand.
762 "', '".$ditag_feature->cigar_line.
"', '".$ditag_feature->ditag_side.
"', ".
763 $ditag_feature->ditag_pair_id.
")";
769 $sql =
"INSERT INTO ditag_feature ( ditag_id, seq_region_id, seq_region_start, ".
770 "seq_region_end, seq_region_strand, analysis_id, hit_start, hit_end, ".
771 "hit_strand, cigar_line, ditag_side, ditag_pair_id ) VALUES ";
772 foreach my $ditag_feature (@good_ditag_features) {
774 if($inserts){ $sqladd =
", " }
775 $sqladd .=
"(". $ditag_feature->ditag_id.
", ".($ditag_feature->slice->get_seq_region_id).
", ".
776 $ditag_feature->start.
", ".$ditag_feature->end.
", '".$ditag_feature->strand.
"', ".
777 $ditag_feature->analysis->dbID.
", ".$ditag_feature->hit_start.
", ".$ditag_feature->hit_end.
778 ", '".$ditag_feature->hit_strand.
"', '".$ditag_feature->cigar_line.
"', '".
779 $ditag_feature->ditag_side.
"', ".$ditag_feature->ditag_pair_id.
")";
787 print STDERR
"\nHave $inserts Features.\n";
792 warning(
"Problem inserting ditag feature batch!".$@.
"\n");
796 warn
"Nothing stored!";
804 Arg [1] : ditagFeature to update
805 Description: update an existing ditagFeature with
new values
806 Returntype : 1 on success
812 my ($self, $ditagFeature) = @_;
814 my $sth = $self->prepare(
"UPDATE ditag_feature
815 SET ditag_id=?, seq_region_id=?, seq_region_start=?, seq_region_end=?,
816 seq_region_strand=?, analysis_id=?, hit_start=?, hit_end=?, hit_strand=?,
817 cigar_line=?, ditag_side=?, ditag_pair_id=?
818 where ditag_feature_id=?;" );
820 $sth->bind_param(1, $ditagFeature->ditag_id, SQL_INTEGER);
821 $sth->bind_param(1, $ditagFeature->seq_region_id, SQL_INTEGER);
822 $sth->bind_param(1, $ditagFeature->seq_region_start, SQL_INTEGER);
823 $sth->bind_param(1, $ditagFeature->seq_region_end, SQL_INTEGER);
824 $sth->bind_param(1, $ditagFeature->seq_region_strand, SQL_TINYINT);
825 $sth->bind_param(1, $ditagFeature->hit_start, SQL_INTEGER);
826 $sth->bind_param(1, $ditagFeature->hit_end, SQL_INTEGER);
827 $sth->bind_param(1, $ditagFeature->hit_strand, SQL_TINYINT);
828 $sth->bind_param(1, $ditagFeature->cigar_line, SQL_LONGVARCHAR);
829 $sth->bind_param(1, $ditagFeature->ditag_side, SQL_VARCHAR);
830 $sth->bind_param(1, $ditagFeature->ditag_pair_id, SQL_INTEGER);
831 $sth->bind_param(1, $ditagFeature->dbID, SQL_INTEGER);
833 my $result =$sth->execute();
842 Example : my @feature_ids = @{$dfa->list_dbIDs()};
843 Description: Gets an array of
internal IDs
for all DitagFeature objects in
844 the current database.
845 Arg[1] : <optional>
int. not 0
for the ids to be sorted by the seq_region.
846 Returntype : List of ints
853 my ($self, $ordered) = @_;
855 return $self->_list_dbIDs(
'ditag_feature', undef, $ordered);