<?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:www.mygrid.org.uk:operation:KDW7Q2VVW20" author="Peter Li" title="Identification of homologs to human FOXO in Drosophila" />
  <s:processor name="seqTo" boring="true">
    <s:stringconstant>251</s:stringconstant>
  </s:processor>
  <s:processor name="e_value" boring="true">
    <s:stringconstant>3.0e-13</s:stringconstant>
  </s:processor>
  <s:processor name="entrezFilter" boring="true">
    <s:stringconstant>Drosophila+melanogaster+%5BORGN%5D</s:stringconstant>
  </s:processor>
  <s:processor name="database" boring="true">
    <s:stringconstant>nr</s:stringconstant>
  </s:processor>
  <s:processor name="MultipleSelectWorker">
    <s:beanshell>
      <s:scriptvalue>// author Peter Li 8 September 2006

/**
 * Class representing the selected values of this beanshell processor
 */
class SelectedValues
{
  ArrayList selectedValues;

  SelectedValues()
  {
    selectedValues = new ArrayList();
  }

  synchronized void addToValues(ArrayList values)
  {
    for(int i = 0; i &lt; values.size(); i ++)
      selectedValues.add(values.get(i));

    notifyAll();
  }

  synchronized ArrayList getValues()
  {
    while (selectedValues.size() == 0)
    {
      try
      {
        wait();
      }
      catch (InterruptedException e)
      {
        e.printStackTrace();
      }
    }

    return selectedValues;
  }
}

/**
 * This class represents the GUI for selecting the values to be
 * processed by the remainder of the workflow.
 */
MultipleSelectWorkerGUI(ArrayList input, SelectedValues values)
{
  JList list;
  DefaultListModel listModel;
  final String submitString = "Submit";
  JButton submitButton;
  int[] accessions;
  SelectedValues selectedValues;
  ArrayList inputdata;
  

  void init()
  {
    super.frame = new JFrame("Select blast hits to workflow");
    pane = new JPanel(); 
    super.frame.getContentPane().add(pane); 
    pane.setLayout(new BorderLayout()); 

    // Set up input data
    inputdata = input;
    listModel = new DefaultListModel();
    for (int i = 0; i &lt; inputdata.size(); i++)
      listModel.addElement(inputdata.get(i));
    
    selectedValues = values;

    //Create the list and put it in a scroll pane
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    list.setSize(300,300);
    list.setFixedCellHeight(20);

    JScrollPane listScrollPane = new JScrollPane(list);

    submitButton = new JButton(submitString);
    submitButton.setActionCommand(submitString);
    submitButton.addActionListener(this);

    //Create a panel
    JPanel buttonPane = new JPanel();
    buttonPane.add(submitButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    pane.add(listScrollPane, BorderLayout.CENTER);
    pane.add(buttonPane, BorderLayout.PAGE_END);

    frame.setVisible(true); 
    frame.pack(); 
  }

  //This method is required by ListSelectionListener.
  void valueChanged(ListSelectionEvent e)
  {
    if (!e.getValueIsAdjusting())
    {
      if (list.getSelectedIndex() == -1)
      {
        //No selection so disable fire button
        submitButton.setEnabled(false);
      }
      else
      {
        //Selection made so enable the fire button.
        submitButton.setEnabled(true);
      }
    }

  }

  void actionPerformed(ActionEvent e)
  {
    ArrayList al = new ArrayList();

    // This method is called only if there is a valid selection
    if (list.getSelectedIndices().length == 0)
    {
      // No accession number selected so disable firing
      submitButton.setEnabled(false);
    }
    else
    {
      accessions = list.getSelectedIndices();
      for(int i = 0; i &lt; accessions.length; i++)
      {
        String str = listModel.elementAt(accessions[i]);
        System.out.println(str);
        String[] strArray = str.split(": ");
        al.add(strArray[0]);
      }
      selectedValues.addToValues(al);
      super.frame.dispose();

    }
  }

  init(); 
  return this; 
}

/**
 * Wrapper for MultipleSelectWorkerGUI
 */ 
class Producer extends Thread
{
  SelectedValues selectedValues;
  ArrayList inputdata;

  Producer(ArrayList input, SelectedValues v)
  {
    inputdata = input;
    selectedValues = v;
  }

  void run()
  {
    msw = MultipleSelectWorkerGUI(inputdata, selectedValues);
  }
}


sv = new SelectedValues();
producer = new Producer(input, sv);
producer.start();
outputData = sv.getValues();</s:scriptvalue>
      <s:beanshellinputlist>
        <s:beanshellinput s:syntactictype="l('text/plain')">input</s:beanshellinput>
      </s:beanshellinputlist>
      <s:beanshelloutputlist>
        <s:beanshelloutput s:syntactictype="l('text/plain')">outputData</s:beanshelloutput>
      </s:beanshelloutputlist>
    </s:beanshell>
  </s:processor>
  <s:processor name="Concat_acc_with_def">
    <s:beanshell>
      <s:scriptvalue>//ArrayList list1;
//ArrayList list2;
outputList = new ArrayList();

for(int i = 0; i &lt; list1.size(); i ++)
{
  String str = (String)list1.get(i) + ": " + (String)list2.get(i);  
  outputList.add(str);  
}</s:scriptvalue>
      <s:beanshellinputlist>
        <s:beanshellinput s:syntactictype="l('text/plain')">list1</s:beanshellinput>
        <s:beanshellinput s:syntactictype="l('text/plain')">list2</s:beanshellinput>
      </s:beanshellinputlist>
      <s:beanshelloutputlist>
        <s:beanshelloutput s:syntactictype="l('text/plain')">outputList</s:beanshelloutput>
      </s:beanshelloutputlist>
    </s:beanshell>
  </s:processor>
  <s:processor name="hFOXO3aProtein" boring="true">
    <s:stringconstant>NP_001446</s:stringconstant>
  </s:processor>
  <s:processor name="xpath_accdef" boring="true">
    <s:stringconstant>//BlastOutput/BlastOutput_iterations/Iteration/Iteration_hits/Hit//Hit_def</s:stringconstant>
  </s:processor>
  <s:processor name="formatType" boring="true">
    <s:stringconstant>XML</s:stringconstant>
  </s:processor>
  <s:processor name="xpath_acc" boring="true">
    <s:stringconstant>//BlastOutput/BlastOutput_iterations/Iteration/Iteration_hits/Hit//Hit_accession</s:stringconstant>
  </s:processor>
  <s:processor name="Merge_string_list_to_string">
    <s:defaults>
      <s:default name="seperator" />
    </s:defaults>
    <s:local>org.embl.ebi.escience.scuflworkers.java.StringListMerge</s:local>
  </s:processor>
  <s:processor name="Concatenate_two_strings">
    <s:local>org.embl.ebi.escience.scuflworkers.java.StringConcat</s:local>
  </s:processor>
  <s:processor name="get_foxo_protein_seq">
    <s:local>net.sourceforge.taverna.scuflworkers.ncbi.ProteinFastaWorker</s:local>
  </s:processor>
  <s:processor name="Get_Nucleotide_FASTA">
    <s:local>net.sourceforge.taverna.scuflworkers.ncbi.NucleotideFastaWorker</s:local>
  </s:processor>
  <s:processor name="XPath_From_Text_accdef">
    <s:local>net.sourceforge.taverna.scuflworkers.xml.XPathTextWorker</s:local>
  </s:processor>
  <s:processor name="XPath_From_Text_acc">
    <s:local>net.sourceforge.taverna.scuflworkers.xml.XPathTextWorker</s:local>
  </s:processor>
  <s:processor name="ebi_refseq">
    <s:description>Please note: This information pertains to the PROTEIN section of RefSeq.</s:description>
    <s:defaults>
      <s:default name="fieldname">AccNumber</s:default>
    </s:defaults>
    <s:soaplabwsdl>http://dbk-ed.mib.man.ac.uk:8080/axis/services/srs_ebi_protsequence.ebi_refseqp</s:soaplabwsdl>
  </s:processor>
  <s:processor name="ncbi_tblastn">
    <s:description>Compares a protein query sequence against a nucleotide sequence database dynamically translated in all reading frames</s:description>
    <s:soaplabwsdl>http://dbk-ed.mib.man.ac.uk:8080/axis/services/ncbi.ncbi_tblastn</s:soaplabwsdl>
  </s:processor>
  <s:processor name="seqFrom" boring="true">
    <s:stringconstant>157</s:stringconstant>
  </s:processor>
  <s:processor name="transeq_ebi">
    <s:description>Translate nucleic acid sequences</s:description>
    <s:soaplabwsdl>http://www.ebi.ac.uk/soaplab/services/nucleic_translation.transeq</s:soaplabwsdl>
  </s:processor>
  <s:processor name="prettyplot">
    <s:description>Displays aligned sequences, with colouring
                  and boxing</s:description>
    <s:soaplabwsdl>http://www.ebi.ac.uk/soaplab/services/alignment_multiple.prettyplot</s:soaplabwsdl>
  </s:processor>
  <s:processor name="emma">
    <s:description>Multiple alignment program - interface to
                  ClustalW program</s:description>
    <s:soaplabwsdl>http://www.ebi.ac.uk/soaplab/services/alignment_multiple.emma</s:soaplabwsdl>
  </s:processor>
  <s:link source="Concat_acc_with_def:outputList" sink="MultipleSelectWorker:input" />
  <s:link source="Concatenate_two_strings:output" sink="emma:sequence_direct_data" />
  <s:link source="Get_Nucleotide_FASTA:outputText" sink="Merge_string_list_to_string:stringlist" />
  <s:link source="Merge_string_list_to_string:concatenated" sink="transeq_ebi:sequence_direct_data" />
  <s:link source="MultipleSelectWorker:outputData" sink="Get_Nucleotide_FASTA:id" />
  <s:link source="XPath_From_Text_acc:nodelist" sink="Concat_acc_with_def:list1" />
  <s:link source="XPath_From_Text_accdef:nodelist" sink="Concat_acc_with_def:list2" />
  <s:link source="database:value" sink="ncbi_tblastn:database" />
  <s:link source="e_value:value" sink="ncbi_tblastn:expect" />
  <s:link source="emma:outseq" sink="prettyplot:sequences_direct_data" />
  <s:link source="entrezFilter:value" sink="ncbi_tblastn:entrez_query" />
  <s:link source="formatType:value" sink="ncbi_tblastn:format_type" />
  <s:link source="get_foxo_protein_seq:outputText" sink="Concatenate_two_strings:string2" />
  <s:link source="hFOXO3aProtein:value" sink="ebi_refseq:searchterm" />
  <s:link source="hFOXO3aProtein:value" sink="get_foxo_protein_seq:id" />
  <s:link source="hFOXO3aProtein:value" sink="ncbi_tblastn:query" />
  <s:link source="ncbi_tblastn:result" sink="XPath_From_Text_acc:xml-text" />
  <s:link source="ncbi_tblastn:result" sink="XPath_From_Text_accdef:xml-text" />
  <s:link source="seqFrom:value" sink="ncbi_tblastn:query_from" />
  <s:link source="seqTo:value" sink="ncbi_tblastn:query_to" />
  <s:link source="transeq_ebi:outseq" sink="Concatenate_two_strings:string1" />
  <s:link source="xpath_acc:value" sink="XPath_From_Text_acc:xpath" />
  <s:link source="xpath_accdef:value" sink="XPath_From_Text_accdef:xpath" />
  <s:link source="ebi_refseq:result" sink="refseq" />
  <s:link source="ncbi_tblastn:result" sink="blast_report" />
  <s:link source="prettyplot:Graphics_in_PNG" sink="multiple_alignment" />
  <s:sink name="blast_report">
    <s:metadata>
      <s:mimeTypes>
        <s:mimeType>text/xml</s:mimeType>
      </s:mimeTypes>
      <s:semanticType>http://www.mygrid.org.uk/ontology#bioinformatics_report</s:semanticType>
    </s:metadata>
  </s:sink>
  <s:sink name="multiple_alignment">
    <s:metadata>
      <s:mimeTypes>
        <s:mimeType>image/png</s:mimeType>
      </s:mimeTypes>
      <s:semanticType>http://www.mygrid.org.uk/ontology#sequence_alignment_report</s:semanticType>
    </s:metadata>
  </s:sink>
  <s:sink name="refseq">
    <s:metadata>
      <s:mimeTypes>
        <s:mimeType>chemical/seq-aa-genpept</s:mimeType>
      </s:mimeTypes>
    </s:metadata>
  </s:sink>
</s:scufl>

