#!/bin/env icarus
# IARC TP53 Germline Database
# Author: Domenico Marra (domenico.marra@istge.it)
# Created: May 7th, 2005
# Modifed on 2008/04/08

$fn={
Function_id:function_id
Protein_description:p_des
WT_AA:wt_aa
Codon_number:cod_no
Mutant_AA:mut_aa
SwissProt_link:swissl
Structural_motif:structural
Codon72_AA:codon72
Conserved_WT_function:consfun
Loss_of_function:lossfun
Dominant_negative_activity:dominant
Gain_of_function:gainf
Temperature_sensitivity:tempsens
Temp_ref:tempref
Cell_assay:cellas
Cell_lines:cell_line
Assay_design:assaydes
Method:method
Ref_id:ref_id
Title:title
Authors:authors
Year:year
Journal:journal
Volume:volume
Start_page:start
PubMed_entry:pubmed
}

$rules={
  entry:	~ {$In:[file:text] $Out pre $Skip:0}
		  ('Function_id' {$Not} ln)*
		  ('Function_id' {$entryFip=$Fip $Wrt} ln {$App}
		  ('Function_id' {$Not} ln {$App})*)?
		~
# fields

  fields:	~ {$In:entry $Out $Skip:1}
                  (/\/[^\n]+\n/ {$Wrt} |
                  word {$Wrt:$fn.$Ct} 
                  (/[\/A-Z]/ {$Not} ln {$App})+)+ ~
 

#indexing

  function_id:	~ {$In:[fields c:function_id] $Out}
		  tag / /* number {$Wrt} ~

  numbers:	~ {$In:[fields c:{cod_no year volume start ref_id swissl}] $Out}
		  tag ' '* number {$Uniq:$Itc} ln ~ 

  wt_aa: 	~ {$In:[fields c:wt_aa] $Out} 
		  tag ' '* (/\n/ | ln {$Uniq:$Itc}) ~ 

  mut_aa: 	~ {$In:[fields c:mut_aa] $Out} 
		  tag ' '* (/\n/ | ln {$Uniq:$Itc}) ~ 

  p_des:       ~ {$In:[fields c:p_des] $Out}
                  tag ' '* ( ln {$Wrt})*~

  tempref:	~ {$In:[fields c:tempref] $Out}
		  tag ' '* word {$Uniq:$Itc} ln ~ 

  journal:	~ {$In:[fields c:journal] $Out}
		  tag ' '* ln {$Uniq:$Itc}~ 

  unique:	~ {$In:[fields c:{title authors journal structural codon72
				consfun lossfun dominant gainf tempsens 
				cellas cell_line assaydes method }] $Out}
		  tag ' '*  (not_word | all {$Uniq:$Itc})*~ 

  strX:		~ {$In:[fields c:{pubmed}] $Out}
		  tag ' '* number {$Uniq:$Itc}  ~ 
#		  tag ' '* ('PM:'|'PU:') ' '* number {$Uniq:$Itc }  ~ 

#HTML stuff...

 h_top:      ~ {$In:[fields c:unique_id t:html] pre if:$ParInt:isTable $Fail}
               word {$Rep:
                     |</TR><TR>
                     |<TD colspan=2 bgcolor=\"#ffffff\">
                     |<font color=\"#000066\"><B><center>
                     |($entry.libName)</center></B></TD>
                     |</TR>
                     |<TR><TD bgcolor=\"#ffffff\">
                     |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                     |<TD bgcolor=\"#ffffff\">
                    } 
                     /.*/ {$Rep:"$Ct</TD></TR>"}  ~

 h_ref: ~ {$In:[fields c:ref_id t:html] pre if:$ParInt:isTable $Fail }
             'Ref_id' {if:$isTable==0
               $Rep:
                 |<TR><TD bgcolor=\"#ffffff\">
                 |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                 |<TD bgcolor=\"#ffffff\">
               }
             punct? number {$Rep:$Hlink:[tp53_som_refR p:{$Ct $Ct}]} ~

 h_pubmed: ~ {$In:[fields c:pubmed t:html] pre if:$ParInt:isTable $Fail }
             'PubMed_entry' {if:$isTable==0
               $Rep:
                 |<TR><TD bgcolor=\"#ffffff\">
                 |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                 |<TD bgcolor=\"#ffffff\">
               }
              ' '*  number {$Rep:$Hlink:[medlineR p:{$Ct $Ct}]} ~
 
 h_fields:      ~ {$In:[fields t:html] pre if:$ParInt:isTable $Fail}
                        word {if:$isTable==0
                        $Rep:
                     |<TR><TD bgcolor=\"#ffffff\">
                     |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                     |<TD bgcolor=\"#ffffff\">
                     } 
                         /.*/ {$Rep:"$Ct</TD></TR>"}  ~

 t_fields:     ~ {$In:[fields] $Out} tag /.*/ {$Wrt:$Itc} ~

# definitions

  tag:          ~ /[0-9a-zA-Z_]+/ ~
  ln:		~ /[^\n]*\n/ ~
  word:		~ /[0-9a-zA-Z_]+/ ~
  word2:	~ /[a-zA-Z+-]+/ ~
  word3:	~ /[0-9a-zA-Z\\.+-]+/ ~
  number:	~ /[0-9]+/ ~
  not_word:	~ /[^a-zA-Z0-9_-]+/ ~ 
  all:  	~ /[0-9a-zA-Z_\\"&>?\\.\\'\\\/\+-]+/ ~ 
  punct:	~ /[^a-zA-Z0-9_]+/ ~

}