ensembl-hive  2.8.1
CaenorhabditisElegans.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
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
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
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.
17 
18 =cut
19 
20 use strict;
21 use warnings;
22 
24 
25 package SeqStoreConverter::CaenorhabditisElegans;
26 
27 use vars qw(@ISA);
28 
30 
31 
32 sub create_coord_systems {
33  my $self = shift;
34 
35  $self->debug("Caenorhabditis Specific: creating " .
36  "clone and chromosome coord systems");
37 
38  my $target = $self->target();
39  my $dbh = $self->dbh();
40 
41  my $ass_def = $self->get_default_assembly();
42 
43  my @coords =
44  (["chromosome" , $ass_def, "default_version" , 1],
45  ["clone", undef , "default_version,sequence_level", 2]);
46 
47  my @assembly_mappings = ("chromosome:$ass_def|clone");
48 
49  $self->debug("Building coord_system table");
50 
51  my $sth = $dbh->prepare("INSERT INTO $target.coord_system " .
52  "(name, version, attrib, rank) VALUES (?,?,?,?)");
53 
54  my %coord_system_ids;
55 
56  foreach my $cs (@coords) {
57  $sth->execute(@$cs);
58  $coord_system_ids{$cs->[0]} = $sth->{'mysql_insertid'};
59  }
60  $sth->finish();
61 
62  $self->debug("Adding assembly.mapping entries to meta table");
63 
64  $sth = $dbh->prepare("INSERT INTO $target.meta(meta_key, meta_value) " .
65  "VALUES ('assembly.mapping', ?)");
66 
67  foreach my $mapping (@assembly_mappings) {
68  $sth->execute($mapping);
69  }
70 
71  $sth->finish();
72 
73  return;
74 }
75 
76 
77 
78 sub create_seq_regions {
79  my $self = shift;
80 
81  $self->debug("CaenorhabditisElegans Specific: creating clone and " .
82  "chromosome seq_regions");
83 
84  $self->contig_to_seq_region('clone');
85  $self->chromosome_to_seq_region();
86 }
87 
88 
89 sub create_assembly {
90  my $self = shift;
91 
92  $self->debug("CaenorhabditisElegans Specific: loading assembly data");
93 
94  $self->assembly_contig_chromosome();
95 }
96 
97 
98 #
99 # override the contig_to_seqregion method so that contigs are given clone
100 # names instead
101 #
102 sub contig_to_seq_region {
103  my $self = shift;
104  my $target_cs_name = shift;
105 
106  my $target = $self->target();
107  my $source = $self->source();
108  my $dbh = $self->dbh();
109 
110  $target_cs_name ||= 'contig';
111 
112  $self->debug("CaenorhabditisElegans Specific: Transforming contigs " .
113  "into $target_cs_name seq_regions");
114 
115  my $cs_id = $self->get_coord_system_id($target_cs_name);
116 
117  my $sth = $dbh->prepare
118  ("INSERT INTO $target.seq_region " .
119  "SELECT ctg.contig_id, CONCAT(cln.embl_acc, '.', cln.embl_version), " .
120  " $cs_id, ctg.length " .
121  "FROM $source.contig ctg, $source.clone cln " .
122  "WHERE ctg.clone_id = cln.clone_id");
123 
124  $sth->execute();
125  $sth->finish();
126 
127  return;
128 }
129 
130 
131 
132 1;
SeqStoreConverter::BasicConverter
Definition: BasicConverter.pm:3