Show AnnotationTool.pl syntax highlighted
#!/usr/bin/perl
use strict "vars";
use vars qw(
$GV
$GVportal
$PRM
@modes
$DBH
$zeroPos
$UCAcgiPATH
$IMAGEDIR
$GENSCAN_speciesModel
);
do 'UCAconf.pl';
do 'functions.pl';
&{$GV->{InitFunction}};
$PRM->{USERid} = &{$GV->{getUserIdFunction}};
$PRM->{owner} = param('owner') ? param('owner') : $PRM->{USERid};
########################
## Access limits to tool
########################
if(!$PRM->{USERid}){
## Request user login for annotation creation
bailOut("You must login first before using this tool. $GV->{dbTitle}");
}
my $isAdmin = &{$GV->{getUserGroupFunction}}($PRM->{USERid});
my $ownedRef = &{$GV->{getAdminOwnershipFunction}};
# if owned and owned by this admin
my $ownedByAnyAdmin = ($$ownedRef{$PRM->{uid}}) ? 1 : 0;
my $ownedByThisAdmin = (($$ownedRef{$PRM->{uid}} eq $PRM->{USERid} )) ? 1 : 0;
my $ownedByThisAdminAnnotator = ($PRM->{USERid} eq $PRM->{owner} ) ? 1 : 0;
if ($PRM->{start} == 0){
$PRM->{start} = 1; # minimum base position is 1
}
if($PRM->{uid} and ($PRM->{modifyState} != "1") ){
# do not requery database for UCA, if page is reloaded for evidence range change
my $loadreturn = &loadUCA();
if (!$loadreturn){
bailOut("No Annotation Exists with that ID");
}
$PRM->{editedUID} = $PRM->{id};
if ( (!$isAdmin) && ($PRM->{USERid} ne $PRM->{owner})){
bailOut("You do not own this annotation.");
}
}
if ($isAdmin && (!$ownedByThisAdmin) && $PRM->{uid} && ($PRM->{owner} ne $PRM->{USERid}) ){
bailOut("You do not have permission to administrate this annotation at this time.");
}
if (($PRM->{start} eq "") or ($PRM->{end} eq "") or ($PRM->{chr} eq "")){
bailOut("Incomplete parameters: chromosome $PRM->{chr}, coordinates $PRM->{start}, $PRM->{end}");
}
#if (($PRM->{imgWidth} != 400)&&($PRM->{imgWidth} != 800)){
# bailOut('Invalid Image Size');
#}
if ($$ownedRef{$PRM->{uid}} && ($$ownedRef{$PRM->{uid}} ne $PRM->{USERid}) ){
bailOut("Annotation $PRM->{geneId} is currently under review");
}
############################
## end Access limits to tool
############################
#####################
## Submission actions
#####################
my ($MSG1,$stat,$MSGclass);
my $mode = $PRM->{mode};
$PRM->{UDEsource} = "$PRM->{Esource}<newline>$PRM->{UDEsource}" ;
#for save, subtract UDE not in structure
if ( ($mode eq "UCAsave") || ($mode eq "UCAsubmit")|| ( $isAdmin and ( ($mode eq "UCAaccept")||($mode eq "UCAreject") ) )){
my @Elines = split /<newline>/, $PRM->{UDEsource};
my @newElines;
for (my $i=0;$i<scalar(@Elines);$i++){
my ($Ecoord) = $Elines[$i] =~ /^(\d+\s\d+)/;
$Ecoord =~ s/\s/\.\./;
if ($PRM->{info} =~ /$Ecoord/ ){
#$PRM->{UDEsource} =~ s/$Elines[$i]//;
$newElines[++$#newElines] = $Elines[$i];
}
}
$PRM->{UDEsource} = join("<newline>",@newElines);
}
$PRM->{Esource} = $PRM->{UDEsource}; # for field
if ($mode eq 'UCAprint'){
print header();
print "<html><body>
<h1>User Contributed Annotation - $GV->{specieName} $GV->{dbTitle}</h1><br>
<hr>
<pre>";
print &printDetail();
print "</pre></body></html>";
exit;
}
if( (($mode eq "UCAsave") || ($mode eq "UCAsubmit")) && ($PRM->{UCAannid} eq "")){
$MSG1 = "Annotation ID is required.";
$MSGclass = 'warning';
$mode = "";
}
if ( ($mode eq "UCAsave") || ($mode eq "UCAsubmit")|| ( $isAdmin and ( ($mode eq "UCAaccept")||($mode eq "UCAreject") ) ) ){
if ( ($isAdmin and !$ownedByThisAdmin and $ownedByAnyAdmin) ){
# if admin has checked out annotation if the annotation is not owned by the admin
bailOut("Your administration session for this annotation has ended. <br> To curate this annotation, please check it out again.");
}
# actions are equivalent except for status field
if ($mode eq 'UCAsave'){
$stat = "SAVED";
}elsif($mode eq 'UCAsubmit') {
$stat = "aREVIEW";
}elsif($mode eq 'UCAaccept') {
$stat = "ACCEPTED";
}elsif($mode eq 'UCAreject') {
$stat = "REJECTED";
}
my $updated = 0;
if($PRM->{uid}){
#### User wants to change annotation name
## Check availability of new entry name
if( &updateAnnotation($stat) ){
$updated = 1;
$PRM->{status} = $stat;
}else{
#### new annotation ID already taken (request different);
$stat = 'NOT SAVED';
if ($PRM->{UCAannid}){
$MSG1 = "The Annotation Id $PRM->{UCAannid} is already in use! Please enter a different identifier and submit again.";
$MSGclass = 'warning';
}else{
$MSG1 = "Annotation ID is required.";
$MSGclass = 'warning';
}
goto LOAD_FIELDS; ## reload submitted form values
}
}elsif($PRM->{info} eq ''){
#### No structure info was reported
$stat = 'NOT SAVED';
$MSG1 = "No structure coordinates were entered. A valid structure is required to save this record!";
goto LOAD_FIELDS; ## reload submitted form values
}elsif( !(&addUserAnnotation($stat)) ){
# if add is successful, else is not, name already taken
$stat = 'NOT SAVED';
$MSG1 = "The Annotation Id $PRM->{UCAannid} is already in use! Please enter a sdifferent identifier and submit again.";
$MSGclass = 'warning';
goto LOAD_FIELDS; ## reload submitted form values
}
# successful submition messages
if ($mode eq 'UCAsave'){
$MSG1 .= "Annotation Id: $PRM->{UCAannid} has been saved for editing at a later time!";
}elsif($mode eq 'UCAsubmit') {
$MSG1 .= "Annotation Id: $PRM->{UCAannid} has been submitted for review!";
}elsif($mode eq 'UCAaccept') {
$MSG1 .= "Annotation Id: $PRM->{UCAannid} has been accepted.";
extraAdminSubmit();
}elsif($mode eq 'UCAreject') {
$MSG1 .= "Annotation Id: $PRM->{UCAannid} has been rejected.";
extraAdminSubmit();
}
if (($PRM->{editedUID} ne $PRM->{id}) and $PRM->{editedUID} ne ""){
$MSG1 .= "<br>Locus $PRM->{editedUID} renamed.";
}
$MSG1 .= "<br><br> Close this window to end this annotation session or continue to make changes and save again.";
$MSGclass= 'success';
$PRM->{status} = $stat;
}elsif($mode eq "UCAdelete"){
$stat = "DELETED";
if($PRM->{uid}){
&removeAnnotation();
}else{
$PRM->{editedUID} = $PRM->{UCAannid};
}
my $PAGE_CONTENTS = "<span class=mainTable><font style='font-weight:bold;font-size:24px'>User Contributed Annotation System<br> Gene Annotation Tool</font><br>
<font style='font-weight:bold;font-size:14px'> $GV->{specieName} ($GV->dbTitle)</font><br><br>
<font style='color:red;font-weight:bold;font-size:14px;'><H3>Locus: $PRM->{UCAannid} id: $PRM->{uid} withdrawn!</H3>
<!--<a href='javascript:this.close();'>Close Window</a></font>--></span>";
goto PRINT_PAGE_CONTENTS;
}
#########################
## end Submission actions
#########################
LOAD_FIELDS:
############################################
## get gene evidence, genome sequence, scale
############################################
my $evidenceHashRef = &{$GV->{EvidenceFunction}};
my $imagelinkALL = &{$GV->{ImageMapFunction}};
$PRM->{GenomeSequence} = &{$GV->{GenomeSeqFunction}};
my ($eTable,$etableJscript) = getEvidenceTable($evidenceHashRef);
my ($scale,$zeroPos,$StartX,$graphicMargin) = &{$GV->{ScaleFunction}};
################################################
## end get gene evidence, genome sequence, scale
################################################
my $maxAmt = 200; #maximum amount of exons
my $leftMargin = 10;
my $RangeChrFIELD = popup_menu(-name=>'chr',-value=>$GV->{CHR_LIST},-default=>$PRM->{chr},-override=>1);
my $navigation = ($GV->{CHR_SELECT_BOX}) ? "<br>Chromosome: $RangeChrFIELD ": "<br>Genome Segment<input type=text readonly size=10 name='chr' value='$PRM->{chr}'><br>";
$navigation .= 'start<input type=text name=RangeStart value='.$PRM->{start}.' size=10> end<input type=text name=RangeEnd value='.$PRM->{end}.' size=10>  ';
$navigation .= '<input type=button value="Change Location" class="buttons" onClick="EvidenceRangeSet();">';
## Form Elements Hash
my %FE = (
"Annotation ID" => textfield(-name=>'UCAannid',-value=>$PRM->{UCAannid},-override=>1,-size=>30,-maxlength=>32),
"Genome Location" => $navigation,
"Strand" => "<input type='radio' name='UCAstrand' value='forward strand' checked='checked' onclick='reverseStrand();'>forward strand   <input type='radio' name='UCAstrand' value='reverse strand' onclick='reverseStrand();'>reverse strand   <input type=button class=buttons value='Reset mRNA structure' onClick='resetMRNA();'>",
"Protein Coding Region" => "<br>Start ".textfield(-name=>'UCAcdsstart',-value=>$PRM->{cds_start},-override=>1,-size=>10,-maxlength=>10,-onChange=>'EnterORF();')." end ".textfield(-name=>'UCAcdsend',-value=>$PRM->{cds_end},-override=>1,-size=>10,-maxlength=>10,-onChange=>'EnterORF();')."<input type=button class=buttons value='ORF Finder' onClick='GORF();'>",
"mRNA Structure" => "<br>".textarea(-name=>'UCAstruct',-value=>$PRM->{info},-override=>1,-rows=>3,-cols=>40,-wrap=>'soft', -onChange=>'structTextEnter();'),
"Description" => "<br>".textarea(-name=>'UCAdesc',-value=>$PRM->{desc},-override=>1,-rows=>3,-cols=>40,-wrap=>'physical'),
"Putative Protein Product" => "<br>".textfield(-name=>'UCAprod',-value=>$PRM->{prod},-override=>1,-size=>30,-maxlength=>32),
"Gene Aliases" => "<br>".textarea(-name=>'UCAannalias',-value=>$PRM->{geneAlias},-override=>1,-rows=>3,-cols=>28,-wrap=>'off'),
"Protein Aliases" => "<br>".textarea(-name=>'UCAprotalias',-value=>$PRM->{protAlias},-override=>1,-rows=>3,-cols=>28,-wrap=>'off'),
"mRNA" => "<input type=text name='mRNAlength' size=30 class='seqLength'><br>"."<textarea wrap='physical' rows='6' cols='50' class=seqTextArea name='mRNAseq' readonly></textarea><br><a href=\"javascript:Blast('n');\">blastn</a>",
"Protein" => "<input type=text name='proteinlength' size=30 class='seqLength'><br>"."<textarea rows='6' wrap='physical' class=seqTextArea cols='50' name='protein' readonly></textarea><br><a href=\"javascript:Blast('p');\">blastp</a>  <a href=\"javascript:Blast('tn');\">tblastn</a>  <a href=\"javascript:Blast('tx');\">tblastx</a>",
"Genome Sequence Edits" => "<br><textarea rows='5' cols='35' name='GSeqEdits' readonly=1>$PRM->{GSeqEdits}</textarea><br><a href=\"javascript:goSeqEdit();\" class='portallink'>Genome Sequence Editor</a><br>\n",
"Gene Annotation Type" => "".popup_menu(-name=>'annotation_type',-value=>$GV->{ANNOTATION_TYPES},-default=>$PRM->{annotation_type})
);
$FE{"User Defined Exons"} = <<END_UDE;
<table cellspacing=0 cellpadding=2 border=0 class=mainTable><tr>
<td>
<div style='border:thin gray solid;'><font class="s2">User-Defined Exons Table</font><br>
<div id='UserBox' style='overflow:auto;height:88px;width:150px;'></div>
</div>
</td>
<td>
<u>Portals</u><br>
<a href="#topA" onClick="GoGSQ();" class="portallink">GeneSeqer at PlantGDB</a><br>
<a href="#topA" onClick="GoGM();" class="portallink">GeneMark</a> <a href="#topA" onClick="GoGS();" class="portallink">GENSCAN</a><br>
<u>Manual Entry</u><br>
start<input type=text name=new5 class=manual size=10><br>
end  <input type=text class=manual name=new3 size=10><a href="javascript:addUDE(document.forms['$GV->{formName}'].new5.value,document.forms['$GV->{formName}'].new3.value,'manual','');" class="portallink">add</a>
</td>
</tr></table>
<input class=buttons type=button value="Clear User-Defined Exons Table" onclick="clearUserExons();updateMRNA();">
END_UDE
my @FEorder1 = ("Annotation ID","Genome Location","Strand");
my @FEorder2 = ("User Defined Exons","mRNA","Protein Coding Region","Protein","mRNA Structure","Gene Annotation Type","Description","Putative Protein Product","Gene Aliases","Protein Aliases","Genome Sequence Edits"); # order of form elements in page
my $GAEVAL = ""; ## need
my $previewStruct = "
<script>
var exonMaxsize = $maxAmt;
var baseScale = $scale;
var pad = $StartX;
var lmargin = $leftMargin;
var StructHeight = 11;
var startCoord = $zeroPos;
var eTableExons = new Object();
$etableJscript
</script>
<table class=preview_struct>
<tr><td !height=11><img src='".$GV->{IMAGEDIR}."tln_start.gif'name='tlnStart' class=previewImage><img src='".$GV->{IMAGEDIR}."tln_stop.gif' name='tlnStop' class=previewImage><\/td><\/tr>
<tr><td height=11 id='refCell'><img src='".$GV->{IMAGEDIR}."leftarrow.gif' name='leftarrow' class=previewImage>";
for (my $i=0;$i<$maxAmt;$i++){
$previewStruct .= '<img name="e'.$i.'" src="'.$GV->{IMAGEDIR}.'e.gif" class=previewImage>';
}
$previewStruct .= "<img src='".$GV->{IMAGEDIR}."i.gif' name='intron' class=previewIntron><img src='".$GV->{IMAGEDIR}."rightarrow.gif' name='rightarrow' class=previewImage><\/td><\/tr><\/table>";
my $imgfn="tmp$$".'.png';
my $GAEVALtxt;
if ($GV->{GAEVAL}){
$GAEVALtxt = "<input class=utButton type=button name='GAEVAL' value='GAEVAL for this annotation' onClick='goGAEVAL();'>";
}
my $TutorialTXT;
if ($GV->{Tutorial}){
$TutorialTXT = '<input class=utButton type=button value="Tutorial" onClick="tutorial();">';
}
#my $GenomePlotSelection = "<font style='font-size:10px;'> change to ".(($PRM->{largeImage}) ? "<a href=\"javascript:changeImageSize(400);\">small image size</a>" : "<a href=\"javascript:changeImageSize(800);\">large image</a>")."</font>";
my $GenomePlotSelection = "<font class='s3'>change image size to </font><select name='imgWidthSel' onChange='changeImageSize();'>
<option value='400' ".(($PRM->{imgWidth} eq '400') ? 'selected': '')." >400</option>
<option value='800' ".(($PRM->{imgWidth} eq '800') ? 'selected': '')." >800</option>
<option value='1200' ".(($PRM->{imgWidth} eq '1200') ? 'selected': '')." >1200</option>
<option value='3000' ".(($PRM->{imgWidth} eq '3000') ? 'selected': '')." >3000</option>
</select>
";
my $GPwidth = ($PRM->{imgWidth} + 2*$graphicMargin);
my $GenomePlot =<<END_GP;
<table border=0 class=mainTable><tr><td>
<font class='s2'>Evidence Plot</font> <a target='_blank' href='$GV->{colorLegendLink}'><font style='font-size:10px;'>(color legend)</font></a>
$GenomePlotSelection
<br><div style='width:${GPwidth}px;height:200px;overflow:auto;border:1px solid gray;' id='ePlotDiv'>$imagelinkALL</div></td></tr>
<tr><td><font style='color:red;font-size:12px;'>Your Structure:</font></td></tr>
<tr><td style='background: white'>$previewStruct<br></td></tr>
</table>
END_GP
###################
## Function Buttons
###################
my $functionButtons;
if ($isAdmin and $ownedByThisAdmin){
$functionButtons = <<END_OF_FB;
<font style="font-weight:bold;font-size:24px">Administration Tool</font><br><br>
<font style="background-color:yellow;">Email Message:</font> (Auto-inserted: "Your annotation was ____.")<br>
<textarea name='emailTXT' id='emailTXT' rows=5 cols=60>$PRM->{emailTXT}<\/textarea><br>
<input class=funcButton type=button name='UCAaccept' value='ACCEPT' onClick=\"formSubmit('UCAaccept','Accepting Annotation into $GV->{dbTitle}','_self');\">
<input class=funcButton type=button name='UCAreject' value='REJECT' onClick=\"formSubmit('UCAreject','Rejecting Annotation','_self');\">
END_OF_FB
#$functionButtons .= ($PRM->{status} ne "ACCEPTED") ? "<input class=funcButton type=button name='UCAaccept' value='ACCEPT' onClick=\"formSubmit('UCAaccept','Accepting Annotation into $GV->{dbTitle}','_self');\">" : "";
#$functionButtons .= ($PRM->{status} ne "REJECTED") ? "<input class=funcButton type=button name='UCAreject' value='REJECT' onClick=\"formSubmit('UCAreject','Rejecting Annotation','_self');\">" : "";
$functionButtons .= "<input class=funcButton type=button name='UCAreload' value='RELOAD' onClick=\"formSubmit('UCAreload','Reloading Annotation','_self');\">";
my $status; ### $status from UCAload
if ($ownedByThisAdminAnnotator){
$functionButtons .= "<input class=funcButton type=button name=\"UCAdelete\" value=\"DELETE\" onClick=\"formSubmit('UCAdelete','Removing Annotation');\">";
# remove function for accepted annotations
}
$functionButtons .= "<br><br><br>";
}elsif(!$GV->{standAlone}){
$functionButtons = <<END_OF_FB;
<input class=funcButton type=button name="UCAsubmit" value="Submit" onClick="formSubmit('UCAsubmit','Submitting Annotation for Review','_self');">
<input class=funcButton type=button name="UCAdelete" value="Remove Annotation" onClick="formSubmit('UCAdelete','Removing Annotation','_self');">
<input class=funcButton type=button name="UCAsave" value="Save for Editing" onClick="formSubmit('UCAsave','Saving Annotation','_self');">
<input class=funcButton type=button value="Reset" onClick="resetAll();">
END_OF_FB
}else{
$functionButtons = "<input class=funcButton type=button name='UCAprint' value='Print Annotation Record to Text' onClick=\"formSubmit('UCAprint','','_blank');\">";
}
#######################
## end Function Buttons
#######################
my ($FIELD_HTML1, $FIELD_HTML2);
$FIELD_HTML1 = "<div class=fieldspace><s1>$FEorder1[0]</s1>$FE{$FEorder1[0]}</div>";
$FIELD_HTML1 .= "<div class=fieldspace><s1>$FEorder1[1]</s1>$FE{$FEorder1[1]}</div>";
$FIELD_HTML1 .= "<div class=fieldspace><s1>$FEorder1[2]</s1>$FE{$FEorder1[2]}    ";
$FIELD_HTML1 .= "<s1>$FEorder1[3]</s1>$FE{$FEorder1[3]}</div>";
for(my $i=0;$i<scalar(@FEorder2);$i++){
$FIELD_HTML2 .= "<div class=fieldspace><s1>$FEorder2[$i]</s1>$FE{$FEorder2[$i]}<br></div>\n";
}
my $PAGE_CONTENTS = <<END_OF_PAGE;
<span class=mainTable>
$functionButtons $GAEVALtxt $TutorialTXT
<br>
<br>
<font class="s1">Annotation Owned By:</font> $PRM->{owner} <font class="s1">Annotation Record Status: </font>$PRM->{status} $PRM->{modDate} $PRM->{modTime}<br>
</span>
END_OF_PAGE
$PAGE_CONTENTS .= (!$PRM->{largeImage}) ? "<table class=mainTable>
<tr>
<tr><td></td></tr>
<td valign=top>$FIELD_HTML1 $FIELD_HTML2</td>
<td width='450px' valign=top height=30 class=mainTable id='EvidenceCell'>$GenomePlot $eTable</td>
</tr>
</table>
" : "
<table class=mainTable>
<tr><td colspan=2>
$FIELD_HTML1
$GenomePlot</td></tr>
<tr>
<td valign=top>$FIELD_HTML2</td>
<td width='430px' valign=top class=mainTable id='EvidenceCell'>$eTable
</td>
</tr>
</table>
";
PRINT_PAGE_CONTENTS: # maybe delete this?
my $main_page =<<END_MAIN_PAGE;
<html><head><title>User Contributed Annotation System: $GV->{dbTitle}</title>
<script src='$GV->{JSPATH}AnnotationTool.php'></script>
<script src='$GV->{JSPATH}utility.txt'></script>
<script src='$GV->{JSPATH}popup.txt'></script>
<LINK type='text/css' rel='stylesheet' href='$GV->{HTMLPATH}UCA.css'>
</head>
<body bgcolor='#FFFFFF' style="margin-left:${leftMargin}px;padding:0">
<div onclick='event.cancelBubble = true;' class=Loadingpopup id=LoadingPopUp>
<center>
<font id=message>Loading.... Please wait</font>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br>
Loading.... Please wait
</center>
</div>
<form name='$GV->{formName}' method=POST action='AnnotationTool.pl'>
<input type=hidden name='owner' value ='$PRM->{owner}'>
<input type=hidden name='start' value='$PRM->{start}'>
<input type=hidden name='end' value='$PRM->{end}'>
<input type=hidden name='seqUID' value='$PRM->{seqUID}'>
<input type=hidden name='USERid' value='$PRM->{USERid}'>
<input type=hidden name='dbid' value='$GV->{dbid}'>
<input type=hidden name='uid' value='$PRM->{uid}'>
<input type=hidden name='UDEsource' value='$PRM->{UDEsource}'>
<input type=hidden name='Esource' value=''>
<input type=hidden name='imgWidth' value='$PRM->{imgWidth}'>
<input type=hidden name='status' value='$PRM->{status}'>
<input type=hidden name='GenomeSequence'> <!--portal-->
<input type=hidden name='UCAname'>
<input type=hidden name='OriginalGenomeSequence' value='$PRM->{GenomeSequence}'>
<input type=hidden name=orfsel value="">
<script>
var GenomeSequence;
var imagePATH = '$GV->{IMAGEDIR}';
var formName = '$GV->{formName}';
var logoPath = '$GV->{logoimagePath}';
var dbTitle = '$GV->{dbTitle}';
</script>
<input type=hidden name='modifyState' value='1'>
<input type=hidden name='mode' value=''>
<span class=mainTable>
<font style='font-weight:bold;font-size:24px'>User Contributed Annotation System<br> Gene Structure Annotation Tool</font><br>
<font style='font-weight:bold;font-size:14px'> $GV->{specieName} ($GV->{dbTitle})</font><br><br>
<table><tr><td class=$MSGclass>$MSG1</td></tr></table><br><br></span>
<br>
$PAGE_CONTENTS
<SCRIPT LANGUAGE='JavaScript'>
first_load();
</SCRIPT>
</form>
<div id=\"blankDiv\" style=\"position: absolute; left: 0; top: 0; visibility: hidden\">
</div>
</body>
END_MAIN_PAGE
print header();
print $main_page;
print end_html();
# CGI works print "\n".$PRM->{mode};
# sourceData works my $evidenceHashRef = getEvidence();print keys(%$evidenceHashRef);
#* get cgi values
#* get valid user, user for annotation
# direct depending on mode
# if mode=edit load db values, if new edit
# if mode=save,submit,delete storage functions
#
# load tool
#* get evidence
#* get image, and genome
# print tool
See more files for this project here