#!/usr/bin/env icarus
# DSMZ Human And Animal Cell Lines Catalogue - Syntax file
# Version 2004.12.17.01
# Last Updated December 17, 2004
# Author: Domenico Marra & Francesca Piersigilli & Paolo Romano
# (c) CABRI 1999-2023

$fn={
  Cell_line_name:cell_name
  Accession_number:acc_no
  Brief_description:brief
  Description:description
  Morphology:morphology
  Culture_conditions:cult_cond
  Viruses:viruses
  Storage:storage
  Properties:properties
  Release_conditions:release
  Doubling_time:double
  Hazard:hazard
  Depositor:depositor
  Mycoplasma:myco
  Bibliographic_reference:refs
  Fingerprint:fingerprint
  Cytogenetics:cyto
}

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

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

#indexing
  acc_no:	~ {$In:[fields c:acc_no] $Out}
		  word ' ' (word2{$Wrt} | punct4)* ~

  cyto:		~ {$In:[fields c:cyto] $Out}
		  word (word3{$Wrt} |/./ | punct3)* ~

  viruses:	~ {$In:[fields c:viruses] $Out}
		  word (word3{$Wrt} | /./ | punct2)* ~

  cell_name:	~ {$In:[fields c:cell_name] $Out}
		   word (word { $Wrt:[s:$StrRep:[s:$Ct r:"[\/|\.|-]" to:""]] }
                   | /./ | punct)* ~

  wordX:	~ {$In:[fields c:{cellname brief description storage depositor
                                 refs morphology double myco
                                  fingerprint}] $Out}
		  word (word{$Uniq:$Itc} | /./ |punct)*  ~

  strX:		~ {$In:[fields c:{cult_cond properties}] $Out}
		  word (str{$Uniq:$Itc} | /./ |punct2)* ~

  release:      ~ {$In:[fields c:release] $Out}
                  word / / (word2{$Wrt} | punct2) ~

  hazard:      ~ {$In:[fields c:hazard] $Out}
                  word / / (number{$Wrt} | /./) ~

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

  h_release: ~ {$In:[fields c:release t:html] $Skip:1 pre if:$ParInt:isTable $Fail}
              'Release_conditions' {if:$isTable==0
                $Rep:
                 |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                 |<font color=\"#000066\"><b><i> $Ct</i></b></font></TD>
                 |<TD bgcolor=\"#ffffff\">
                }
                / /  (word2 {$rest=$Ct.rep:[' ' to:'%20']
                               $Rep:$Hlink:[dsmz_mutz_resR p:{$rest $Ct}]})~

  h_hazard: ~ {$In:[fields c:hazard t:html] $Skip:1 pre if:$ParInt:isTable $Fail}
              'Hazard' {if:$isTable==0
                $Rep:
                 |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                 |<font color=\"#000066\"><b><i> $Ct</i></b></font></TD>
                 |<TD bgcolor=\"#ffffff\">
                }
                / /?  ('-'|
                       number {$Rep:$Hlink:[dsmz_mutz_hazR p:$Ct]})~ 

  h_fields: ~ {$In:[fields xc:refs t:html] pre if:$ParInt:isTable $Fail} 
               word {if:$isTable==0 
	         $Rep:
                   |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                   |<font color=\"#000066\"><b><i>$Ct</i></b></font></TD>
                   |<TD bgcolor=\"#ffffff\">
                  } 
                  ':'? {$Rep:""} /.*/ {$Rep:"$Ct</TD></TR>"}  ~


 h_biblio_ref:  ~ {$In:[fields c:refs t:html]
                       pre if:$ParInt:isTable $Fail}
                  bib_tag {if:$isTable==0 $Rep:
                        |<TR VALIGN=TOP><TD bgcolor=\"#ffffff\">
                        |<font color=\"#000066\">
                        |<b><i>$Ct</i></b></font></TD>
                        |<TD bgcolor=\"#ffffff\">
                       }
                  /[^\\[]*/
                  ('[PMID: ' pmid {$Rep:$Hlink:[pubmedCabriR p:{$Ct $Ct}]} ']')?
                  x{$Rep:"</TD></TR>"}  ~


  t_fields: ~ {$In:[fields] $Out} tag /.*/ {$Wrt:$Itc} ~
 
# definitions
  tag:          ~ word ':'? ~
  bib_tag:      ~ ('Bibliographic_reference'|'Further_bibliography') ~
  bib_word:     ~ /[a-zA-Z]+/ ~
  bib_vol:      ~ (number bib_punct?)+ ~
  bib_punct:    ~ /[;:.-]/ ~
  pmid:         ~ /[0-9]+/ ~
  ln:		~/[^\n]*\n/ ~
  word:		~/[0-9a-zA-Z_\\.\\?\/-]+/ ~
  word2:        ~/[ 0-9a-zA-Z_\\.\\?\/-]+/ ~
  word3:        ~/[0-9a-zA-Z_;:\\.\\?\/\\+\\(\\)\\%<>-]+/ ~
  punct:	~ /[ \t,;:\\(\\)\\.\\+\\*]+/ ~  
  punct2:	~ /[ \t,:]+/ ~  
  punct3:	~ /[ \t,]+/ ~  
  punct4:	~ /[\t,:]+/ ~  
  str:		~/[a-zA-Z0-9&.;'=\/\\?\\(\\)\\+\\%_-]+/ ~
  number:       ~ /[0-9]+/ ~
}