Create a Tag Instance

There are several parts of Softparsmap that can be replace in order to meet more specific needs. The parts are defined by the interfaces in the package. Here is an example on how to create a new parser and install it.

My Parser Code

Let the java file MyParser.java contain following lines.


  import softparsmap.*;
  import ooc.*

  public class MyParser extends AbstractTreeParser {

    public Node parseIn(String tree) {
      // The code for parsing the string 'tree' goes here.
      // The method returns the root to the parsed gene tree.
    }

    public void parseIn(Node tree, String treeInfo) {
      // The code for parsing in additional information into the 
      // tree nodes goes here
    }

    public String parseOut(Node tree) {
      // The code for parsing the gene tree 'tree' to a
      // string goes here.
      // getting an attribute value
      String value = getAttributeString("some_attribute");
      // rest of your code
    }
    
  }
      
Add the parse in and out code and then compile the class by typing javac MyParser.java. If it will not compile, the CLASSPATH has probably not been set correctly. More information on how to set the class path is found at Solaris or at Windows.

My Property File

Since MyParser.java extends the AbstractTreeParser it is a good idea to extend the abstract tag defined in def.xml as well. This is because the abstract tag have some default attributes which are used by the abstract class. Your property file will then look something like this.


    <?xml version="1.0" encoding="iso-8859-1"?>

    <source title="My Project Name">

      <!-- Importing package definitions -->
      <import source="softparsmap/def.xml" source_context="classpath"/>
      
      <!--
      Your tasks, data sources and family groups can be defined here in
      which you are using your new parser with did="my_parser"
      -->
      
      <!-- Defining my parser -->
      <tree_parser did="my_parser" eid="abstract"
                   class="MyParser"
		   some_attribute="@@string:=some value"
		   />
      
    </source>
      
The attribute class is changed from AbstractTreeParser to MyParser in order to connect the new code to the tag.