6 /markers/cosii_files.mas - a Mason component displaying information about cosii associated information in files
16 $marker - a CXGN::Marker object.
22 Lukas Mueller <lam87@cornell.edu>
34 use CXGN::Accession::Tools;
36 my $marker_name = $marker->get_name();
37 my $dbh = $marker->{dbh};
38 unless($marker->is_in_collection('COSII')){return'';}
39 my($html,$html1,$html2,$html3,$html4,$html5,$html6)=('','','','','','');
40 my $header = "<hr />";
41 my $cosii_files=cosii_data_files( $marker, $c->config )->{all_other_data_files};
43 for my $additional_data_file(sort {$a cmp $b} @{$cosii_files}) {
45 my $real_location=$additional_data_file;
46 my $data_shared_website_path=$c->config->{'static_datasets_path'};
47 $real_location=~s/$data_shared_website_path//;
48 $real_location=URI::Escape::uri_escape($real_location);
49 my $display_name=$additional_data_file;
51 if($additional_data_file=~/([^\/]+)$/){$display_name=$1;}
52 if($display_name=~/\.blastx$/) {
53 $description = 'BLASTX result of original unigene sequences against Arabidopsis protein database';
54 $html1.="<a href=\"$additional_data_file\">$description</a><br />";
56 elsif($display_name=~/[^FRfr]+\.cds\.fasta$/) {
57 $description = 'Alignment of Arabidopsis CDS and edited Asterid unigenes, FASTA';
58 $html2.="<a href=\"$additional_data_file\">$description</a><br />";
60 elsif($display_name=~/\.aligned2aa$/) {
61 $description= 'Alignment of DNA and translated peptides from Arabidopsis CDS and edited Asterid unigenes, plain text';
62 $html2.="<a href=\"$additional_data_file\">$description</a><br />";
64 elsif($display_name=~/\.pep\.aln$/) {
65 $description = 'Alignment of translated peptides from Arabidopsis CDS and edited Asterid unigenes, ClustalW';
66 $html2.="<a href=\"$additional_data_file\">$description</a><br />";
68 elsif($display_name=~/\.pep\.fasta$/) {
69 $description='Alignment of translated peptides from Arabidopsis CDS and edited Asterid unigenes, FASTA';
70 $html2.="<a href=\"$additional_data_file\">$description</a><br />";
72 elsif($display_name=~/\.cds\.nex$/) {
73 $description='Input file for PAUP, NEXUS format';
74 $html3.="<a href=\"$additional_data_file\">$description</a><br />";
76 elsif($display_name=~/\.ml\.tre$/) {
77 $description='Phylogenetic tree';
78 $html3.="<a href=\"$additional_data_file\">$description</a><br />";
79 my $file_url=URI::Escape::uri_escape($additional_data_file);
80 $html3.="<a href=\"$additional_data_file\">$description</a> | <a href=\"/tools/tree_browser/?shared_file=$file_url\">[View]</a><br />";
82 elsif($display_name=~/\.cds\.fasta$/) {
83 $description = 'Amplicon sequence alignment, FASTA';
84 $html4.="<a href=\"$additional_data_file\">$description</a><br />";
86 elsif($display_name=~/\.txt$/ or $display_name=~/\.seq$/) {
87 $description=&_cosii_additional_description($dbh, $display_name).", plain text";
88 $html4.="<a href=\"$additional_data_file\">$description</a><br />";
90 elsif($display_name=~/\.pdf$/) {
91 $description=&_cosii_additional_description($dbh, $display_name).", PDF chromatogram";
92 $html4.="<a href=\"$additional_data_file\">$description</a><br />";
94 elsif($display_name=~/\.ab1$/) {
95 $description=&_cosii_additional_description($dbh, $display_name).", AB1 chromatogram";
96 $view_link=" - <a href=\"/tools/trace_view.pl?file=$real_location\">[View]</a>";
97 $html4.="<a href=\"$additional_data_file\">$description</a> $view_link<br />";
99 elsif($display_name=~/\.cds\.txt$/) {
100 $description = 'Original unigene seqs and Arabidopsis CDS seq, FASTA';
104 $description=$display_name;
105 $html6.="<a href=\"$additional_data_file\">$description</a><br />";
109 my $html7 = &cosii_files_html_2($dbh, $marker_name);
111 if($html1){$html.=$header.$html1;}
112 if($html2){$html.=$header.$html2;}
113 if($html3){$html.=$header.$html3;}
114 if($html4){$html.=$header.$html4;}
115 if($html5){$html.=$header.$html5;}
116 if($html6){$html.=$header.$html6;}
117 if($html7){$html.=$html7;}
118 if($html){$html.=$header;}
120 print CXGN::Page::FormattingHelpers::blue_section_html('Other COSII sequence data',$html);
124 sub cosii_files_html_2 {
126 my $marker_name = shift;
129 $marker_name =~ s/C2_At//;
132 my $table = "forward_amplicon_sequence_markers";
134 my $select = "select ending from $table where marker_name = '$marker_name' order by ending;";
136 my $sth = $dbh->prepare("$select");
139 while (my $ending = $sth->fetchrow()) {
140 $html .= &get_information($dbh, $marker_name, $ending);
149 sub get_information {
150 my ($dbh, $marker,$ending) = @_;
152 my $cosii_file = $c->config->{'cosii_files'};
154 my $table = "forward_amplicon_sequence_information";
157 my ($number, $dashnumber, $parennumber) = "";
158 if ($ending =~ /(\w+)-(\d+)/) {
161 $dashnumber = "-$number";
162 $parennumber = " ($number)";
164 my $select = "select organism_name, accession_id, plant_number "
165 . "from $table where ending = '$ending';";
166 my $sth = $dbh->prepare("$select");
168 my ($organism, $accession, $plant) = $sth->fetchrow();
170 ($plant eq '0') ? ($plant="") : ($plant = " plant #$plant");
171 ($accession eq '0') ? ($accession="") : ($accession=" $accession");
173 my $ab1 = "$cosii_file/ab1/$marker-$ending$dashnumber.ab1";
174 my $seq = "$cosii_file/seq/$marker-$ending$dashnumber.seq";
175 my $text = "Forward amplicon sequence for $organism$accession$plant$parennumber,";
177 $html .= "<a href=\"$ab1\">$text AB1 chromatogram</a> - "
178 . "<a href=\"/tools/trace_view.pl?file=$ab1\">[View]</a><br />"
179 . "<a href=\"$seq\">$text plain text</a><br />";
185 sub _cosii_additional_description {
186 my($dbh, $display_name)=@_;
187 my $additional_description='';
188 if($display_name=~/([FRfr])(\d+)[\-\.]/) {
190 my $accession_abbr=$2;
192 if($direction=~/[fF]/){$additional_description='Forward';}
193 if($direction=~/[rR]/){$additional_description='Reverse';}
194 if($accession_abbr) {
195 my @accession_ids=CXGN::Accession::Tools::partial_name_to_ids($dbh,$accession_abbr);
196 if(@accession_ids==1) {
197 my $accession_object=CXGN::Accession->new($dbh,$accession_ids[0]);
198 $additional_description.=' amplicon sequence for '.$accession_object->verbose_name();
201 $additional_description.=" sequence for $accession_abbr";
206 $additional_description=$display_name;
208 return $additional_description;
213 sub cosii_data_files {
214 my ($marker, $conf) = @_;
216 unless($marker->is_in_collection('COSII')){return;}
217 my $cosii_data_files={};
218 my $seq_file_search_string=CXGN::Marker::Tools::cosii_name_to_seq_file_search_string($marker->name_that_marker());
219 my $data_shared_website_path=$conf->{'static_datasets_path'};
220 my $additional_data_files_string=`find $data_shared_website_path/cosii -type f -iregex ".*$seq_file_search_string.*"`;
221 my @files=split("\n",$additional_data_files_string);
222 my @edited_seq_files;
223 my @peptide_seq_files;
224 my @intron_seq_files;
225 my @all_other_data_files;
226 for my $file(@files) {
227 my $data_shared_url=$conf->{'static_datasets_url'};
228 $file=~s/$data_shared_website_path/$data_shared_url/;
229 if($file=~/\.cds\.txt\.modify$/) {
230 push(@edited_seq_files,$file);
232 elsif($file=~/\.pep\.txt$/) {
233 push(@peptide_seq_files,$file);
235 elsif($file=~/\.intron.txt$/) {
236 push(@intron_seq_files,$file);
239 push(@all_other_data_files,$file);
242 $cosii_data_files->{edited_seq_files}=\@edited_seq_files;
243 $cosii_data_files->{peptide_seq_files}=\@peptide_seq_files;
244 $cosii_data_files->{intron_seq_files}=\@intron_seq_files;
245 $cosii_data_files->{all_other_data_files}=\@all_other_data_files;
246 $cosii_data_files->{all_files}=\@files;
247 return $cosii_data_files;