Class 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 Detail

      • TaxonSQL

        public TaxonSQL()
        Deprecated.
    • Method Detail

      • 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:
        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:
        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
      • 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
      • 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
      • 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
      • 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