<?xml version="1.0" encoding="UTF-8"?>
<s:scufl xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha" version="0.2" log="0">
  <s:workflowdescription lsid="urn:lsid:net.sf.taverna:wfDefinition:b5e94288-98d7-4f7c-9190-a7306c9f9416" author="" title="smiles-substructure-idlist" />
  <s:processor name="structure" boring="true">
    <s:stringconstant>c1ccncc1Cl</s:stringconstant>
  </s:processor>
  <s:processor name="format" boring="true">
    <s:stringconstant>eFormat_SMILES</s:stringconstant>
  </s:processor>
  <s:processor name="InputStructure_in">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLInputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="InputStructure" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}InputStructure">
          <s:elements>
            <s:basetype optional="false" unbounded="false" typename="string" name="structure" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;InputStructure&gt;structure" />
            <s:basetype optional="false" unbounded="false" typename="string" name="format" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;InputStructure&gt;format" />
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="InputStructure_out">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLOutputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="InputStructureResponse" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}InputStructureResponse">
          <s:elements>
            <s:basetype optional="false" unbounded="false" typename="string" name="StrKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;InputStructureResponse&gt;StrKey" />
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="GetIDList_out">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLOutputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="GetIDListResponse" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}GetIDListResponse">
          <s:elements>
            <s:arraytype optional="false" unbounded="false" wrapped="true" typename="ArrayOfInt" name="IDList" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;GetIDListResponse&gt;IDList">
              <s:elementtype>
                <s:basetype optional="false" unbounded="false" typename="int" name="" qname="{http://www.w3.org/2001/XMLSchema}int" />
              </s:elementtype>
            </s:arraytype>
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="InputStructure">
    <s:description>Import structure(s) from
        text format (SMILES, SMARTS, SDF, InChI) and get 'structure key' back. Asynchronous.</s:description>
    <s:arbitrarywsdl>
      <s:wsdl>http://pubchem.ncbi.nlm.nih.gov/pug_soap/pug_soap.cgi?wsdl</s:wsdl>
      <s:operation>InputStructure</s:operation>
    </s:arbitrarywsdl>
  </s:processor>
  <s:processor name="GetIDList_in">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLInputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="GetIDList" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}GetIDList">
          <s:elements>
            <s:basetype optional="false" unbounded="false" typename="string" name="ListKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;GetIDList&gt;ListKey" />
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="GetIDList">
    <s:description>Retrieve the list of PubChem
        CIDs hidden behind ListKey. Synchronous.</s:description>
    <s:arbitrarywsdl>
      <s:wsdl>http://pubchem.ncbi.nlm.nih.gov/pug_soap/pug_soap.cgi?wsdl</s:wsdl>
      <s:operation>GetIDList</s:operation>
    </s:arbitrarywsdl>
  </s:processor>
  <s:processor name="SubstructureSearch">
    <s:description>Substructure search by query
        specified in the first parameter (structure key). Searchable subset can be limited by
        specifying list_key. Asynchronous.</s:description>
    <s:arbitrarywsdl>
      <s:wsdl>http://pubchem.ncbi.nlm.nih.gov/pug_soap/pug_soap.cgi?wsdl</s:wsdl>
      <s:operation>SubstructureSearch</s:operation>
    </s:arbitrarywsdl>
  </s:processor>
  <s:processor name="SubstructureSearch_in">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLInputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="SubstructureSearch" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}SubstructureSearch">
          <s:elements>
            <s:basetype optional="false" unbounded="false" typename="string" name="StrKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;SubstructureSearch&gt;StrKey" />
            <s:complextype optional="true" unbounded="false" typename="StructureSearchOptions" name="ssOptions" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;SubstructureSearch&gt;ssOptions">
              <s:elements>
                <s:basetype optional="true" unbounded="false" typename="string" name="MatchIsotopes" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;MatchIsotopes" />
                <s:basetype optional="true" unbounded="false" typename="string" name="MatchCharges" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;MatchCharges" />
                <s:basetype optional="true" unbounded="false" typename="string" name="MatchTautomers" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;MatchTautomers" />
                <s:basetype optional="true" unbounded="false" typename="string" name="RingsNotEmbedded" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;RingsNotEmbedded" />
                <s:basetype optional="true" unbounded="false" typename="string" name="SingeDoubleBondsMatch" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;SingeDoubleBondsMatch" />
                <s:basetype optional="true" unbounded="false" typename="string" name="ChainsMatchRings" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;ChainsMatchRings" />
                <s:basetype optional="true" unbounded="false" typename="string" name="StripHydrogen" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;StripHydrogen" />
                <s:basetype optional="true" unbounded="false" typename="string" name="eStereo" qname="{http://pubchem.ncbi.nlm.nih.gov/}StructureSearchOptions&gt;eStereo" />
              </s:elements>
            </s:complextype>
            <s:complextype optional="true" unbounded="false" typename="LimitsType" name="limits" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;SubstructureSearch&gt;limits">
              <s:elements>
                <s:basetype optional="true" unbounded="false" typename="int" name="seconds" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;seconds" />
                <s:basetype optional="true" unbounded="false" typename="int" name="maxRecords" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;maxRecords" />
                <s:basetype optional="true" unbounded="false" typename="string" name="ListKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;ListKey" />
              </s:elements>
            </s:complextype>
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="SubstructureSearch_in_limits">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLInputSplitter
      <s:extensions>
        <s:complextype optional="true" unbounded="false" typename="LimitsType" name="limits" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;SubstructureSearch&gt;limits">
          <s:elements>
            <s:basetype optional="true" unbounded="false" typename="int" name="seconds" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;seconds" />
            <s:basetype optional="true" unbounded="false" typename="int" name="maxRecords" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;maxRecords" />
            <s:basetype optional="true" unbounded="false" typename="string" name="ListKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}LimitsType&gt;ListKey" />
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="maxRecords" boring="true">
    <s:stringconstant>500</s:stringconstant>
  </s:processor>
  <s:processor name="SubstructureSearch_out">
    <s:local>
      org.embl.ebi.escience.scuflworkers.java.XMLOutputSplitter
      <s:extensions>
        <s:complextype optional="false" unbounded="false" typename="SubstructureSearchResponse" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}SubstructureSearchResponse">
          <s:elements>
            <s:basetype optional="false" unbounded="false" typename="string" name="ListKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;SubstructureSearchResponse&gt;ListKey" />
          </s:elements>
        </s:complextype>
      </s:extensions>
    </s:local>
  </s:processor>
  <s:processor name="StatusCheck">
    <s:workflow maxretries="100" retrydelay="10000" critical="true">
      <s:scufl version="0.2" log="0">
        <s:workflowdescription lsid="urn:lsid:net.sf.taverna:wfDefinition:36b55808-18e0-4269-ad57-7084227c7b77" author="" title="status-check" />
        <s:processor name="GetOperationStatus_out">
          <s:local>
            org.embl.ebi.escience.scuflworkers.java.XMLOutputSplitter
            <s:extensions>
              <s:complextype optional="false" unbounded="false" typename="GetOperationStatusResponse" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}GetOperationStatusResponse">
                <s:elements>
                  <s:basetype optional="false" unbounded="false" typename="string" name="status" qname="{http://pubchem.ncbi.nlm.nih.gov/}&gt;GetOperationStatusResponse&gt;status" />
                </s:elements>
              </s:complextype>
            </s:extensions>
          </s:local>
        </s:processor>
        <s:processor name="Fail_if_false">
          <s:local critical="true">org.embl.ebi.escience.scuflworkers.java.FailIfFalse</s:local>
        </s:processor>
        <s:processor name="GetOperationStatus">
          <s:description>Query for asynchronous
        operation status by AnyKey returned when operation was spawned.</s:description>
          <s:arbitrarywsdl>
            <s:wsdl>http://pubchem.ncbi.nlm.nih.gov/pug_soap/pug_soap.cgi?wsdl</s:wsdl>
            <s:operation>GetOperationStatus</s:operation>
          </s:arbitrarywsdl>
        </s:processor>
        <s:processor name="CheckForSuccess">
          <s:beanshell>
            <s:scriptvalue>if (!(status.equals("eStatus_Success") ||
	status.equals("eStatus_Running") ||
	status.equals("eStatus_Queued") ||
        status.equals("eStatus_HitLimit") ||
        status.equals("eStatus_TimeLimit")))
{
	throw new Exception("Request error - job has failed");
}
success = (status.equals("eStatus_Success") ||  status.equals("eStatus_HitLimit") || status.equals("eStatus_TimeLimit")).toString();</s:scriptvalue>
            <s:beanshellinputlist>
              <s:beanshellinput s:syntactictype="'text/plain'">status</s:beanshellinput>
            </s:beanshellinputlist>
            <s:beanshelloutputlist>
              <s:beanshelloutput s:syntactictype="'text/plain'">success</s:beanshelloutput>
            </s:beanshelloutputlist>
            <s:dependencies s:classloader="iteration" />
          </s:beanshell>
        </s:processor>
        <s:processor name="GetOperationStatus_in">
          <s:local>
            org.embl.ebi.escience.scuflworkers.java.XMLInputSplitter
            <s:extensions>
              <s:complextype optional="false" unbounded="false" typename="GetOperationStatus" name="parameters" qname="{http://pubchem.ncbi.nlm.nih.gov/}GetOperationStatus">
                <s:elements>
                  <s:basetype optional="false" unbounded="false" typename="string" name="AnyKey" qname="{http://pubchem.ncbi.nlm.nih.gov/}AnyKeyType&gt;AnyKey" />
                </s:elements>
              </s:complextype>
            </s:extensions>
          </s:local>
        </s:processor>
        <s:link source="KeyIn" sink="KeyOut" />
        <s:link source="CheckForSuccess:success" sink="Fail_if_false:test" />
        <s:link source="GetOperationStatus_in:output" sink="GetOperationStatus:parameters" />
        <s:link source="KeyIn" sink="GetOperationStatus_in:AnyKey" />
        <s:link source="GetOperationStatus:parameters" sink="GetOperationStatus_out:input" />
        <s:link source="GetOperationStatus_out:status" sink="CheckForSuccess:status" />
        <s:source name="KeyIn" />
        <s:sink name="KeyOut" />
      </s:scufl>
    </s:workflow>
  </s:processor>
  <s:link source="GetIDList:parameters" sink="GetIDList_out:input" />
  <s:link source="GetIDList_in:output" sink="GetIDList:parameters" />
  <s:link source="InputStructure:parameters" sink="InputStructure_out:input" />
  <s:link source="InputStructure_in:output" sink="InputStructure:parameters" />
  <s:link source="InputStructure_out:StrKey" sink="SubstructureSearch_in:StrKey" />
  <s:link source="StatusCheck:KeyOut" sink="GetIDList_in:ListKey" />
  <s:link source="SubstructureSearch:parameters" sink="SubstructureSearch_out:input" />
  <s:link source="SubstructureSearch_in:output" sink="SubstructureSearch:parameters" />
  <s:link source="SubstructureSearch_in_limits:output" sink="SubstructureSearch_in:limits" />
  <s:link source="SubstructureSearch_out:ListKey" sink="StatusCheck:KeyIn" />
  <s:link source="format:value" sink="InputStructure_in:format" />
  <s:link source="GetIDList_out:IDList" sink="output" />
  <s:link source="maxRecords:value" sink="SubstructureSearch_in_limits:maxRecords" />
  <s:link source="structure:value" sink="InputStructure_in:structure" />
  <s:sink name="output" />
</s:scufl>

