3 CXGN::Cview::Map::SGN::Contig - a class to generate maps of contigs aligned to the genome
7 my $map = CXGN::Cview::Map::SGN::Contig->new($dbh, $id);
8 my $chr = $map->get_chromosome(1);
13 The FPC data is currently stored in a berkeleydb database. It is accessed using the following methods:
15 my $db = Bio::DB::GFF->new( -adaptor => 'berkeleydb',
16 -dsn => '/data/local/cxgn/core/sgn/documents/gbrowse/databases/fpc/SGN_2009');
18 and then you can do all the Bio::DB::GFF things with it, do 'perldoc Bio::DB::GFF' to see.
22 Lukas Mueller <lam87@cornell.edu>
26 This class implements the following functions:
30 package CXGN
::Cview
::Map
::SGN
::Contig
;
35 use CXGN
::Cview
::Map
::SGN
::Genetic
;
36 use CXGN
::Cview
::Chromosome
::Physical
;
37 use CXGN
::Cview
::Marker
::Physical
;
40 use base qw
| CXGN
::Cview
::Map
::SGN
::Genetic
|;
45 Arguments: a database handle (preferably generated through
46 CXGN::DB::Connection) and a map id. Currently,
47 only one map_id is supported, with the alpha-
48 numeric id of "contig".
61 my $db_version_id = get_db_id
($dbh, $id);
62 my $self = $class -> SUPER
::new
($dbh, $db_version_id);
64 # if (!defined($self)) { return undef; }
65 $self->set_preferred_chromosome_width(18);
66 $self->set_short_name($args->{short_name
});
67 $self->set_long_name($args->{long_name
});
68 $self->{gbrowse_fpc
} = $args->{gbrowse_fpc
};
69 $self->{temp_dir
} = $args->{temp_dir
} || '/tmp';
70 $self->set_abstract($args->{abstract
});
71 $self->{marker_link
} = $args->{marker_link
};
80 =head2 function get_chromosome()
94 my $map_factory = CXGN
::Cview
::MapFactory
->new($self->get_dbh());
95 my $id = get_db_id
($self->get_dbh(), $self->get_id());
96 #print STDERR "get_chromosome $id.\n";
97 my $genetic_map = $map_factory->create({map_version_id
=>$id});
98 my $genetic=$genetic_map->get_chromosome($chr_nr);
99 my $chromosome = CXGN
::Cview
::Chromosome
::Physical
->new();
101 my $largest_offset = 0;
104 # my $gff = Bio::DB::GFF->new(
105 # -adaptor => 'berkeleydb',
106 # -dsn => $self->{berkeley_db_path},
108 my (@gff) = $self->{gbrowse_fpc
}->databases();
109 if (@gff > 1) { die "Can't deal with multiple databases right now..."; }
110 if (!@gff) { die "No database found!"; }
113 foreach my $m ($genetic->get_markers()) {
114 $m->set_chromosome($chromosome);
115 $chromosome->add_marker($m);
116 my $offset = $m->get_offset();
117 if ($offset > $largest_offset) {
118 $largest_offset=$offset;
122 my @gff_markers = $gff->features(-method
=> 'marker',
123 -attributes
=> { Name
=> $m->get_name() },
126 foreach my $gm (@gff_markers) {
127 @contigs = $gm->refseq();
130 foreach my $c (@contigs) {
131 my $contig = CXGN
::Cview
::Marker
::Physical
->new();
132 $contig->set_chromosome($chromosome);
133 $contig->set_name($c);
135 #my $url = "/gbrowse/gbrowse/sanger_tomato_fpc/?name=$c";
136 my $url = $self->{gbrowse_fpc
}->view_url({ name
=> $c });
137 $contig->set_marker_name($c);
138 $contig->set_marker_type("contig");
139 $contig->set_url($url);
140 $contig->set_offset($m->get_offset());
141 $contig->get_label()->set_name($c);
142 $contig->get_label()->set_url($url);
143 $contig->set_tooltip("Contig: $c. Anchored to: ".($m->get_name()).".");
144 $chromosome -> add_marker
($contig);
148 $chromosome->set_length($largest_offset);
149 $self->{chr}->[$chr_nr]=$chromosome;
154 =head2 function get_overview_chromosome()
164 sub get_overview_chromosome
{
168 my $bargraph = CXGN
::Cview
::Chromosome
::BarGraph
->new();
170 my $largest_offset = 0;
172 my $chromosome = $self->get_chromosome($chr_nr);
174 foreach my $m ($chromosome->get_markers()) {
175 if ($m->get_marker_type() eq "contig") {
176 my $offset = $m->get_offset();
177 $bargraph -> add_association
("manual", $offset, 1);
178 if ($offset>$largest_offset) { $largest_offset = $offset; }
184 =head2 function get_chromosome_connections()
194 sub get_chromosome_connections
{
198 # this map has no connections.!!!!
199 # push @list, { map_version_id=>CXGN::Cview::Map::Tools::find_current_version($self->get_dbh(), CXGN::Cview::Map::Tools::current_tomato_map_id), lg_name=>$chr_nr, marker_count=>"?", short_name=>"F2-2000" };
207 $db_id=~s/^.*(\d+)$/$1/;
208 return CXGN
::Cview
::Map
::Tools
::find_current_version
($dbh, $db_id);
216 sub get_marker_link
{
219 if ($clone_id) { return ""; }
223 sub get_marker_count
{
229 my @lengths = $self->cache_marker_counts();
230 return $lengths[$chr_nr-1];
233 sub cache_marker_counts
{
237 my $temp_file = File
::Spec
->catfile($self->{temp_dir
}, 'contig'.$self->get_id()."_marker_counts.txt");
239 if (! -e
($temp_file)) {
240 open(my $TEMP, ">$temp_file") || die "Can't open $temp_file for writing.";
243 my $chr = $self->get_chromosome($c);
244 foreach my $m ($chr->get_markers()) {
245 if ($m->get_marker_name()=~ /^ctg/) {
249 print $TEMP "$c\t$count\n";
255 open(my $TEMP, "<$temp_file") || die "Can't open $temp_file for reading.";
258 my ($c, $length) = split /\t/;
259 push @lengths, $length;
270 foreach my $c (1..12) {
271 $count += $self->get_marker_count($c);
274 return "$count contigs have been assigned to this map";