﻿<extension>
  <title>Semantic topsan</title>
  <copyright>
    GNU Free Documentation License Copyright 2007 Free Software Foundation, Inc.
    <ulink url="http://opensource.org/licenses/gpl-3.0.html">
      http://opensource.org/licenses/gpl-3.0.html
    </ulink>
  </copyright>
  <namespace>note</namespace>
  <description>This extension contains functions for creating semantic web syntax</description>
  <function>
    <name>link</name>
    <param name="predicate" type="str">Predicate</param>
    <param name="object" type="str">Object </param>
    <param name="visible" type="bool" optional="true">Allow to hide output links (default: true)</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript" xmlns:tps="http://purl.org/topsan/tps">
        <head>
        </head>
        <body>
          <eval:if test="args.object != ''">
          <eval:block value="var semanticlnkMap = {GO:'http://purl.org/obo/owl/GO#GO_', 
          PFAM:'http://purl.org/obo/owl/Pfam#Pfam_',
          UNIPROT:'http://purl.uniprot.org/uniprot/',
          EC:'http://purl.org/obo/owl/EC#EC_',
          TOPSAN:'http://purl.org/topsan/protein/',
          PDB:'http://www.pdb.org/pdb/explore/explore.do?structureId=',
          TAXON:'http://purl.org/obo/owl/NCBITaxon#NCBITaxon_',
          PMID:'http://purl.uniprot.org/citations/'};
          var clicklnkMap = {GO:'http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?term=GO:', 
          PFAM:'http://pfam.sanger.ac.uk/family?acc=',
          UNIPROT:'http://www.uniprot.org/uniprot/',
          EC:'http://www.genome.jp/dbget-bin/www_bget?',
          TOPSAN:'http://www.topsan.org/explore?pdbId=',
		  TAXON:'http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=',
		  PMID:'http://www.ncbi.nlm.nih.gov/pubmed/'
          };">
            <eval:block value="var term = ''; var objectlist = string.split(args.object, ':');">
              <eval:if test="#objectlist > 1 &amp;&amp; map.contains(semanticlnkMap, objectlist[0])">
                <eval:if test="objectlist[1] != ''">
                  <span eval:about="'http://purl.org/topsan/protein/'..page.title" >
                    <span eval:rel="'TPS:'..args.predicate" eval:resource="semanticlnkMap[objectlist[0]]..objectlist[1]" />
                    <eval:if test="args.visible != false">
                      <a eval:href="clicklnkMap[objectlist[0]]..objectlist[1]" ><eval:expr>args.object</eval:expr></a>
                    </eval:if>
                  </span>
                </eval:if>
              </eval:if>
              <eval:else>
                <eval:if test="args.visible != false">
                  <eval:expr>args.object</eval:expr>
                </eval:if>
              </eval:else>
            </eval:block>
          </eval:block>
          </eval:if>
        </body>
      </html>
    </return>
  </function>
</extension>

