Class TaxonSQL


  • public class TaxonSQL
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      TaxonSQL()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static Taxon addName​(java.sql.Connection conn, Taxon taxon, java.lang.String nameClass, java.lang.String newName)
      Deprecated.
      Adds a new name of the given nameClass to the taxon.
      static void attemptClose​(java.sql.ResultSet resultset)
      Deprecated.
      Attempt to close the ResultSet.
      static void attemptClose​(java.sql.Statement statement)
      Deprecated.
      Attempt to close the Statement.
      static void automaticUpdate​(java.sql.Connection conn, DBHelper helper, TaxonFactory factory, java.io.File delnodes, java.io.File merged)
      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.
      static java.lang.String[] getAllScientificNames​(java.sql.Connection conn)
      Deprecated.
      Returns all the scientific names, which are currently stored in the database.
      static java.util.Stack getChildrenOf​(java.sql.Connection conn, java.lang.String scientificName)
      Deprecated.
      Returns all children of the specified taxon.
      static java.util.Stack getChildrenOf​(java.sql.Connection conn, Taxon t)
      Deprecated.
      Returns the children as a Stack of this given taxon.
      static Taxon getDBTaxon​(java.sql.Connection conn, int taxon_id)
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified taxon_id (i.e.
      static java.lang.String getRealScientificName​(Taxon t)
      Deprecated.
      This returns the true scientific name of a given taxon, if there is one.
      static Taxon getTaxon​(java.sql.Connection conn, int ncbi_taxon_id)
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified NCBI taxon ID.
      static Taxon getTaxon​(java.sql.Connection conn, java.lang.String name)
      Deprecated.
      Attempts to get a Taxon object corresponding to the specified name.
      static java.util.Set NCBIids​(java.sql.Connection conn)
      Deprecated.
      Returns a Set of all NCBI-Taxon-IDs which are currently stored in the database.
      static int putTaxon​(java.sql.Connection conn, DBHelper helper, Taxon taxon)
      Deprecated.
      Adds a Taxon (along with its parents) to the database.
      static void removeGeneticCodeID​(java.sql.Connection conn, DBHelper helper, Taxon tdb)
      Deprecated.
      Deletes the genetic code annotation from the taxon in the database.
      static void removeLeftValue​(java.sql.Connection conn, DBHelper helper, Taxon tdb)
      Deprecated.
      Deletes the left value from the specified taxon in the database.
      static void removeMitochondrialGeneticCodeID​(java.sql.Connection conn, DBHelper helper, Taxon tdb)
      Deprecated.
      Deletes the so called mitochondrial genetic code annotation from the given taxon.
      static Taxon removeName​(java.sql.Connection conn, DBHelper helper, Taxon taxon, java.lang.String nameClass, java.lang.String oldName)
      Deprecated.
      Deletes the specified name from of the taxon from the database.
      static void removeRank​(java.sql.Connection conn, DBHelper helper, Taxon tdb)
      Deprecated.
      Removes the rank persistently from the taxon in the database.
      static void removeRightValue​(java.sql.Connection conn, DBHelper helper, Taxon tdb)
      Deprecated.
      Deletes the right value from the specified taxon in the database.
      static Taxon removeTaxon​(java.sql.Connection conn, int ncbi_id, DBHelper helper)
      Deprecated.
      Deletes the taxon given by it's NCBI-Taxon-ID from the database and returns the removed taxon.
      static Taxon removeTaxon​(java.sql.Connection conn, DBHelper helper, java.lang.String name)
      Deprecated.
      Deletes a taxon specified by one of it's names with all it's different names, annotations and sequences from the database.
      static Taxon setCommonName​(java.sql.Connection conn, Taxon taxon, java.lang.String newName)
      Deprecated.
      With this method the common name of the given taxon can be changed or created, if there was none before.
      static void setGeneticCodeID​(java.sql.Connection conn, Taxon tdb, int id)
      Deprecated.
      Updates the taxon in the database and sets its genetic code id to the specified value.
      static void setLeftValue​(java.sql.Connection conn, Taxon tdb, int left)
      Deprecated.
      Updates the taxon and sets the left value to the specified value.
      static void setMitochondrialGeneticCodeID​(java.sql.Connection conn, Taxon tdb, int id)
      Deprecated.
      Updates the given taxon and sets it's so called mitochondrial genetic code id to the specified value.
      static void setParent​(java.sql.Connection conn, Taxon child, Taxon parent)
      Deprecated.
      This updates the taxonomic tree in the database and sets the parent of the given child taxon to the parent taxon.
      static void setRank​(java.sql.Connection conn, Taxon tdb, java.lang.String rank)
      Deprecated.
      Updates a taxon and sets it's rank to the specified String.
      static void setRightValue​(java.sql.Connection conn, Taxon tdb, int right)
      Deprecated.
      Updates the taxon in the database and sets the right value to the specified value.
      static Taxon setScientificName​(java.sql.Connection conn, Taxon taxon, java.lang.String newName)
      Deprecated.
      This changes the scientific name of the given taxon and stores the new name persistent in the database.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TaxonSQL

        public TaxonSQL()
        Deprecated.
    • Method Detail

      • getTaxon

        public static Taxon getTaxon​(java.sql.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​(java.sql.Connection conn,
                                       int taxon_id)
                                throws java.sql.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:
        java.sql.SQLException
        ChangeVetoException
      • putTaxon

        public static int putTaxon​(java.sql.Connection conn,
                                   DBHelper helper,
                                   Taxon taxon)
                            throws java.sql.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:
        taxon - a Taxon. The Taxon must be annotated with the NCBI taxon id (key=EbiFormat.PROPERTY_ORGANISM).
        helper - for the certain database system which is in use.
        Returns:
        an int that corresponds to the Taxon in the database.
        Throws:
        java.sql.SQLException
      • attemptClose

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

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

        public static Taxon getTaxon​(java.sql.Connection conn,
                                     java.lang.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

        public static java.lang.String[] getAllScientificNames​(java.sql.Connection conn)
                                                        throws BioRuntimeException
        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 java.lang.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 java.util.Set NCBIids​(java.sql.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​(java.sql.Connection conn,
                                        DBHelper helper,
                                        java.lang.String name)
                                 throws java.sql.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
        java.sql.SQLException
      • removeTaxon

        public static Taxon removeTaxon​(java.sql.Connection conn,
                                        int ncbi_id,
                                        DBHelper helper)
                                 throws BioRuntimeException,
                                        java.sql.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
        helper - the helper for the database
        ncbi_id - the ncbi-id
        Returns:
        the taxon wich is not stored in the database anymore.
        Throws:
        BioRuntimeException
        BioException
        java.sql.SQLException
      • setScientificName

        public static Taxon setScientificName​(java.sql.Connection conn,
                                              Taxon taxon,
                                              java.lang.String newName)
                                       throws java.sql.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:
        java.sql.SQLException
      • setCommonName

        public static Taxon setCommonName​(java.sql.Connection conn,
                                          Taxon taxon,
                                          java.lang.String newName)
                                   throws BioException,
                                          java.sql.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
        java.sql.SQLException
      • addName

        public static Taxon addName​(java.sql.Connection conn,
                                    Taxon taxon,
                                    java.lang.String nameClass,
                                    java.lang.String newName)
                             throws BioException,
                                    java.sql.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
        java.sql.SQLException
        BioRuntimeException
      • removeName

        public static Taxon removeName​(java.sql.Connection conn,
                                       DBHelper helper,
                                       Taxon taxon,
                                       java.lang.String nameClass,
                                       java.lang.String oldName)
                                throws BioException,
                                       java.sql.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
        java.sql.SQLException
      • getChildrenOf

        public static java.util.Stack getChildrenOf​(java.sql.Connection conn,
                                                    java.lang.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
        java.sql.SQLException
      • getChildrenOf

        public static java.util.Stack getChildrenOf​(java.sql.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​(java.sql.Connection conn,
                                   Taxon tdb,
                                   java.lang.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.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​(java.sql.Connection conn,
                                           DBHelper helper,
                                           TaxonFactory factory,
                                           java.io.File delnodes,
                                           java.io.File merged)
                                    throws java.io.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:
        java.io.IOException