5 use CXGN
::Chromatogram
;
7 use CatalystX
::GlobalContext
'$c';
9 my $page = CXGN
::Page
->new( "Chromatogram viewer", "john" );
10 my ( $file, $temp ) = $page->get_encoded_arguments( 'file', 'temp' );
13 #do not accept files specified with /. because that might be an attempt to view some other file that they
14 #are not allowed to view
15 if ( $file =~ /\/\
./ ) {
16 $page->message_page( 'Invalid file location.',
17 '', '', "Invalid file location: $file" );
20 #if it's a tempfile, look in the tempfile location
22 $file =~ /^[\w\-]+\.mct$/
23 or $page->message_page( 'Invalid file location.',
24 '', '', "Invalid file location: $file" )
25 ; #i made up the extension 'mct' for 'mystery chromatogram type' since we have various kinds of chromatograms and nothing recorded about their file types. --john
27 $c->config->{'basepath'}
28 . $c->config->{'tempfiles_subdir'}
33 #otherwise it will be in data shared
35 my $data_shared_url = $c->config->{'static_datasets_url'};
36 my $data_shared_website_path =
37 $c->config->{'static_datasets_path'};
39 #find cosii chromatogram
40 if ( $file =~ /^$data_shared_url\/cosii2?\
/[\w\-\/]+\
.ab1
$/ ) {
41 $file =~ s/$data_shared_url/$data_shared_website_path/;
44 #or find pgn chromatogram
45 elsif ( $file =~ /trace_files/ ) {
47 s/trace_files/data\/prod\
/public\/pgn_data_processing\
/processed_traces\//;
52 $page->message_page( 'Invalid file location.',
53 '', '', "Invalid file location: $file" );
57 my $temp_image_filename;
58 if ( $file =~ /([\w\-\.]+)\.\w+$/ ) {
59 $temp_image_filename = $1;
62 $page->message_page( 'Invalid file location.',
63 '', '', "Invalid file location: $file" );
65 "/cgi-bin/tools/trace_view.pl: invalid file location: $file\n";
70 if ( CXGN
::Chromatogram
::is_abi_file
($file) ) {
71 $display_pngfile = CXGN
::Chromatogram
::create_image_file
( $file,
72 "$temp_image_filename.png" );
75 my $uncompressed_file =
76 $c->config->{'basepath'}
77 . $c->config->{'tempfiles_subdir'}
78 . "/traceimages/$temp_image_filename"
80 CXGN
::Chromatogram
::uncompress_if_necessary
( $file,
82 if ( CXGN
::Chromatogram
::is_abi_file
($uncompressed_file) ) {
84 CXGN
::Chromatogram
::create_image_file
( $uncompressed_file,
85 "$temp_image_filename.png" );
89 'Sorry, but the viewer does not support this type of chromatogram file.'
95 $page->message_page( 'Invalid file location.',
96 '', '', "Chromatogram file not found at $file" );
98 "/cgi-bin/tools/trace_view.pl: invalid file location: $file\n";
102 $page->header("Chromatogram viewer: $temp_image_filename");
104 "<center><h4>$temp_image_filename</h4></center><img src=\"$display_pngfile\" border=\"0\">";
108 $page->message_page('Invalid arguments.');