Class TaxonSQL

java.lang.Object
org.biojava.bio.seq.db.biosql.TaxonSQL

public class TaxonSQL extends Object
Deprecated.
Use hibernate and org.biojavax.bio.db.*
Methods for retrieving, storing and manipulate Taxa stored in a BioSQL database.
Author:
Len Trigg, Andreas Dräger
  • Constructor Details

    • TaxonSQL

      public TaxonSQL()
      Deprecated.
  • Method Details

    • getTaxon

      public static Taxon getTaxon(Connection conn, int ncbi_taxon_id)
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified NCBI taxon ID.
      Parameters:
      conn - the connection to the database
      ncbi_taxon_id - the NCBI taxon ID.
      Returns:
      the corresponding Taxon (which may have already been present in memory after an earlier retrieval), or null if the Taxon could not be found in the database.
    • getDBTaxon

      public static Taxon getDBTaxon(Connection conn, int taxon_id) throws SQLException, ChangeVetoException
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified taxon_id (i.e. the database's internal id for the taxon).
      Parameters:
      conn - the connection to the database
      taxon_id - the database-specific id for the Taxon.
      Returns:
      the corresponding Taxon (which may have already been present in memory after an earlier retrieval).
      Throws:
      SQLException
      ChangeVetoException
    • putTaxon

      public static int putTaxon(Connection conn, DBHelper helper, Taxon taxon) throws SQLException
      Deprecated.
      Adds a Taxon (along with its parents) to the database. If it is already present in the database, no action is taken. Returns the id by which the database refers to the specified Taxon object.
      Parameters:
      helper - for the certain database system which is in use.
      taxon - a Taxon. The Taxon must be annotated with the NCBI taxon id (key=EbiFormat.PROPERTY_ORGANISM).
      Returns:
      an int that corresponds to the Taxon in the database.
      Throws:
      SQLException
    • attemptClose

      public static void attemptClose(Statement statement)
      Deprecated.
      Attempt to close the Statement. Continue on if there is a problem during the close.
    • attemptClose

      public static void attemptClose(ResultSet resultset)
      Deprecated.
      Attempt to close the ResultSet. Continue on if there is a problem during the close.
    • getTaxon

      public static Taxon getTaxon(Connection conn, String name) throws BioRuntimeException
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified name.
      Parameters:
      conn - the connection to the database
      name - the species scientific name
      Returns:
      the corresponding Taxon (which may have already been present in memory after an earlier retrieval), or null if the Taxon could not be found in the database.
      Throws:
      BioRuntimeException
    • getAllScientificNames

      Deprecated.
      Returns all the scientific names, which are currently stored in the database.
      Parameters:
      conn - connection to the database
      Returns:
      array of lexicographically sorted Strings
      Throws:
      BioRuntimeException
    • getRealScientificName

      public static String getRealScientificName(Taxon t)
      Deprecated.
      This returns the true scientific name of a given taxon, if there is one. This is necessary because if a taxon does not have a parent node, a TaxonFactory gives the scientific name 'ROOT' and the real scientific name (if there is one) is only stored in the taxon's EbiFormat-annotation. This name 'ROOT' applies only for in memory taxon objects. In the database the real name is stored.
      Parameters:
      t - the taxon
      Returns:
      Name of the taxon.
    • NCBIids

      public static Set NCBIids(Connection conn) throws BioRuntimeException
      Deprecated.
      Returns a Set of all NCBI-Taxon-IDs which are currently stored in the database. So it is easy to proove if a taxon is stored in the database or perform other operations.
      Parameters:
      conn - database connection
      Returns:
      a Set containing all NCBI-IDs.
      Throws:
      BioRuntimeException
    • removeTaxon

      public static Taxon removeTaxon(Connection conn, DBHelper helper, String name) throws SQLException, BioException
      Deprecated.
      Deletes a taxon specified by one of it's names with all it's different names, annotations and sequences from the database. This cannot be undone. The removed taxon will be returned.
      Parameters:
      conn - database connection
      helper - the helper for the certain database system to be used.
      name - one of the taxon's names
      Returns:
      the taxon, which was successfully removed and which is not longer stored in the database.
      Throws:
      BioException
      SQLException
    • removeTaxon

      public static Taxon removeTaxon(Connection conn, int ncbi_id, DBHelper helper) throws BioRuntimeException, SQLException, BioException
      Deprecated.
      Deletes the taxon given by it's NCBI-Taxon-ID from the database and returns the removed taxon.
      Parameters:
      conn - database connection
      ncbi_id - the ncbi-id
      helper - the helper for the database
      Returns:
      the taxon wich is not stored in the database anymore.
      Throws:
      BioRuntimeException
      BioException
      SQLException
    • setScientificName

      public static Taxon setScientificName(Connection conn, Taxon taxon, String newName) throws SQLException
      Deprecated.
      This changes the scientific name of the given taxon and stores the new name persistent in the database.
      Parameters:
      conn - database connection
      taxon - the taxon to be changed
      newName - the new scientific name
      Returns:
      the changed taxon with the new scientific name.
      Throws:
      SQLException
    • setCommonName

      public static Taxon setCommonName(Connection conn, Taxon taxon, String newName) throws BioException, SQLException
      Deprecated.
      With this method the common name of the given taxon can be changed or created, if there was none before. The new common name will be stored persitently.
      Parameters:
      conn - database connection
      taxon - the taxon to be updated
      newName - the new common name
      Returns:
      the updated taxon.
      Throws:
      BioException
      SQLException
    • addName

      public static Taxon addName(Connection conn, Taxon taxon, String nameClass, String newName) throws BioException, SQLException, BioRuntimeException
      Deprecated.
      Adds a new name of the given nameClass to the taxon. However, there must be exactly one scientific name and maximal one common name. Otherwise an Exception will be thrown.
      Parameters:
      conn - database connection
      taxon - the taxon to be updated
      nameClass - the name_class of the new name.
      newName - the new name.
      Returns:
      the persistently updated taxon.
      Throws:
      BioException
      SQLException
      BioRuntimeException
    • removeName

      public static Taxon removeName(Connection conn, DBHelper helper, Taxon taxon, String nameClass, String oldName) throws BioException, SQLException
      Deprecated.
      Deletes the specified name from of the taxon from the database. The scientific name has to be uniqe, so this cannot be removed by this method.
      Parameters:
      conn - the database connection
      helper - the helper for the used database system
      taxon - the taxon to be updated
      nameClass - the name_class of the name to be removed
      oldName - the old name, which is not needed anymore.
      Returns:
      the updated taxon.
      Throws:
      BioException
      SQLException
    • getChildrenOf

      public static Stack getChildrenOf(Connection conn, String scientificName) throws BioException
      Deprecated.
      Returns all children of the specified taxon.
      Parameters:
      conn - database connection
      scientificName - name of the taxon which children should be searched.
      Returns:
      a Stac, which contains the children sorted by theire scientific names from top to the bottom.
      Throws:
      BioException
      SQLException
    • getChildrenOf

      public static Stack getChildrenOf(Connection conn, Taxon t) throws BioException
      Deprecated.
      Returns the children as a Stack of this given taxon.
      Parameters:
      conn - database connection
      t - the parent taxon
      Returns:
      a sorted Stack of the children, which might be empty, but not null.
      Throws:
      BioException
    • setRank

      public static void setRank(Connection conn, Taxon tdb, String rank) throws BioRuntimeException
      Deprecated.
      Updates a taxon and sets it's rank to the specified String.
      Parameters:
      conn - database connection.
      tdb - taxon to be updated
      rank - the new rank (like 'kingdom', 'genus' or what ever)
      Throws:
      BioRuntimeException
    • removeRank

      public static void removeRank(Connection conn, DBHelper helper, Taxon tdb) throws BioRuntimeException
      Deprecated.
      Removes the rank persistently from the taxon in the database.
      Parameters:
      conn -
      helper -
      tdb -
      Throws:
      BioRuntimeException
    • setGeneticCodeID

      public static void setGeneticCodeID(Connection conn, Taxon tdb, int id) throws BioRuntimeException
      Deprecated.
      Updates the taxon in the database and sets its genetic code id to the specified value.
      Parameters:
      conn -
      tdb -
      id -
      Throws:
      BioRuntimeException
    • removeGeneticCodeID

      public static void removeGeneticCodeID(Connection conn, DBHelper helper, Taxon tdb) throws BioRuntimeException
      Deprecated.
      Deletes the genetic code annotation from the taxon in the database.
      Parameters:
      conn -
      helper -
      tdb -
      Throws:
      BioRuntimeException
    • setMitochondrialGeneticCodeID

      public static void setMitochondrialGeneticCodeID(Connection conn, Taxon tdb, int id) throws BioRuntimeException
      Deprecated.
      Updates the given taxon and sets it's so called mitochondrial genetic code id to the specified value.
      Parameters:
      conn -
      tdb -
      id -
      Throws:
      BioRuntimeException
    • removeMitochondrialGeneticCodeID

      public static void removeMitochondrialGeneticCodeID(Connection conn, DBHelper helper, Taxon tdb) throws BioRuntimeException
      Deprecated.
      Deletes the so called mitochondrial genetic code annotation from the given taxon.
      Parameters:
      conn -
      helper -
      tdb -
      Throws:
      BioRuntimeException
    • setLeftValue

      public static void setLeftValue(Connection conn, Taxon tdb, int left) throws BioRuntimeException
      Deprecated.
      Updates the taxon and sets the left value to the specified value.
      Parameters:
      conn -
      tdb -
      left -
      Throws:
      BioRuntimeException
    • removeLeftValue

      public static void removeLeftValue(Connection conn, DBHelper helper, Taxon tdb) throws BioRuntimeException
      Deprecated.
      Deletes the left value from the specified taxon in the database.
      Parameters:
      conn -
      helper -
      tdb -
      Throws:
      BioRuntimeException
    • setRightValue

      public static void setRightValue(Connection conn, Taxon tdb, int right) throws BioRuntimeException
      Deprecated.
      Updates the taxon in the database and sets the right value to the specified value.
      Parameters:
      conn -
      tdb -
      right -
      Throws:
      BioRuntimeException
    • removeRightValue

      public static void removeRightValue(Connection conn, DBHelper helper, Taxon tdb) throws BioRuntimeException
      Deprecated.
      Deletes the right value from the specified taxon in the database.
      Parameters:
      conn -
      helper -
      tdb -
      Throws:
      BioRuntimeException
    • setParent

      public static void setParent(Connection conn, Taxon child, Taxon parent) throws BioRuntimeException
      Deprecated.
      This updates the taxonomic tree in the database and sets the parent of the given child taxon to the parent taxon.
      Parameters:
      conn -
      child -
      parent -
      Throws:
      BioRuntimeException
    • automaticUpdate

      public static void automaticUpdate(Connection conn, DBHelper helper, TaxonFactory factory, File delnodes, File merged) throws IOException
      Deprecated.
      This method tries to perform a complete update according to the given TaxonFactory, which already contains the newes taxa and the files available at the NCBI-FTP-Site.
      Parameters:
      conn - database connection
      helper - helper for the database system to be used
      factory - the TaxonFactory containing all the new taxa
      delnodes - file containing the ncbi taxon ids which don't exist anymore
      merged - file containing the ncbi taxon ids which were merged.
      Throws:
      IOException