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