add logfile conf variable
[sgn.git] / cgi-bin / sequencing / bac_registry_discrepancies.pl
blob0530abd9e6755a347095febe4b4c44aa78bd0a0b
1 use strict;
2 use warnings;
4 use Carp;
5 use FindBin;
6 use Getopt::Std;
8 use File::Find;
9 use File::Basename;
11 use CXGN::DB::Connection;
13 use CXGN::Metadata;
14 use CXGN::Genomic::CloneIdentifiers qw/parse_clone_ident/;
15 use CXGN::Genomic::Clone;
16 use CXGN::Genomic::Search::Clone;
17 use CXGN::Tools::Identifiers qw/link_identifier/;
19 use CXGN::Page;
20 use CXGN::Page::FormattingHelpers qw/columnar_table_html/;
21 use CatalystX::GlobalContext qw( $c );
23 my $page = CXGN::Page->new('BAC Registry <-> FTP Discrepancies','Robert Buels');
25 $page->header('BAC Registry <-> FTP Discrepancies','BAC Registry <-> FTP Discrepancies');
27 my $ftp_path = $c->config->{'ftpsite_root'};
29 if(-d $ftp_path ) {
30 my %sequenced_bacs = map {
31 my ($bacname,$dirname) = fileparse($_,qr|\..+$|)
32 or return;
33 my $parsed = parse_clone_ident($bacname,'agi_bac_with_chrom')
34 or return;
35 # $parsed->{match} eq $bacname
36 # or return;
37 $parsed->{dirname} = $dirname;
39 #return
40 ($bacname => $parsed)
41 } glob(File::Spec->catfile($ftp_path,'tomato_genome','bacs','chr*','*finished','*.tar.gz'));
43 my @discrepancies;
44 my @sequenced_bac_names = sort keys %sequenced_bacs;
46 foreach my $bacname (@sequenced_bac_names) {
47 my $clone = CXGN::Genomic::Clone->retrieve_from_parsed_name($sequenced_bacs{$bacname})
48 or die "Could not retrieve clone $bacname\n";
49 $sequenced_bacs{$bacname}->{clone_object} = $clone;
50 my $dirname = $sequenced_bacs{$bacname}->{dirname};
51 my $truestatus = $dirname =~ m|unfinished| ? 'in_progress' : 'complete';
52 my ($chr_from_dir) = $dirname =~ /chr(\d{2})/;
53 $chr_from_dir += 0; #make sure it's numeric
54 $sequenced_bacs{$bacname}->{true_status} = $truestatus;
55 unless( $clone->sequencing_status eq $truestatus ) {
56 push @discrepancies,
58 # $clone->clone_id,
59 $clone->chromosome_num || $chr_from_dir,
60 link_identifier($clone->clone_name_with_chromosome || $clone->clone_name,'bac'),
61 $truestatus,
62 $clone->sequencing_status,
63 # $dirname,
66 # else {
67 # print "actually right!\n";
68 # }
71 #now find all the BACs that are marked complete in the database and aren't
72 #found on the filesystem
73 my $search = CXGN::Genomic::Search::Clone->new;
74 my $query = $search->new_query;
75 $query->sequencing_status('=?','complete');
76 my $results = $search->do_search($query);
77 $results->autopage($query,$search);
78 while (my $clone = $results->next_result) {
79 my $chrname = $clone->clone_name_with_chromosome;
80 # print $clone->clone_name." = $chrname\n";
81 unless ( my $record = $sequenced_bacs{$chrname} ) {
82 push @discrepancies,
84 # $clone->clone_id,
85 $clone->chromosome_num || '',
86 link_identifier($chrname,'bac'),
87 'not present',
88 $clone->sequencing_status,
89 # '',
92 # else {
93 # print "actually right!\n"
94 # }
97 print( '<center>',
98 columnar_table_html( headings => ['Chr','Name','On FTP','In Database'],
99 data => [sort {$a->[0] <=> $b->[0]
100 || $a->[1] cmp $b->[1]
101 } @discrepancies
103 __tableattrs => 'width="50%" cellspacing="0"',
105 '</center>',
107 } else {
108 print '<center>Sorry, this page is temporarily unavailable.</center>';
111 $page->footer;