コード例 #1
0
 def get_cfg_db(self):
     db     = connect_to_mysql()
     cursor = db.cursor()
     qry    = "show databases like'%exoloc%config%'" 
     rows   = search_db (cursor, qry, verbose=False)
     if (not rows):
         print "config database not found (by guessing)"
         print "pls fix config_reader.py"
         cursor.close()
         db.close()
         exit (1)
     self.cfg_db_name = rows[0][0]
     #print "reading config from ", self.cfg_db_name
     cursor.close()
     db.close()
コード例 #2
0
            qry_leaf = leaf

    tree.build(cursor)
    #find cousins for the qry leaf (recursively)
    cousins = find_cousins(qry_leaf)

    return [qry_species] + cousins


#####################################
if __name__ == '__main__':

    local_db = False

    if local_db:
        db = connect_to_mysql()
    else:
        db = connect_to_mysql(user="******",
                              passwd="sqljupitersql",
                              host="jupiter.private.bii",
                              port=3307)
    cursor = db.cursor()

    [all_species, ensembl_db_name] = get_species(cursor)

    tree = Tree()
    for species in all_species:
        tree.add(cursor, species)
    tree.build(cursor)

    print tree.nhx_string()
コード例 #3
0
    def load_cfg(self):
        '''
        Load a configuration file and add the
        key, value pairs to the internal configuration dictionary
        '''
        db     = connect_to_mysql(self.user, self.passwd, self.host, self.port)
        cursor = db.cursor()
        switch_to_db (cursor, self.cfg_db_name)
        
        # utils
        qry = "select name, path from util_path"
        rows   = search_db (cursor, qry, verbose=False)
        if (not rows):
            print "no util_path info in %s" % self.cfg_db_name
            cursor.close()
            db.close()
            sys.exit (1)
        for row in rows:
            [name, path] = row
            if (self.check and not os.path.exists(path)):
                print path, " not found "
                sys.exit (1)
            self.util_path[name] = path

        # utils
        qry  = "select name, path from dir_path"
        rows = search_db (cursor, qry, verbose=False)
        if (not rows):
            print "no dir_path info in %s" % self.cfg_db_name
            cursor.close()
            db.close()
            sys.exit (1)
        for row in rows:
            [name, path] = row
            if (self.check and not os.path.exists(path)):
                print path, " not found "
                sys.exit (1)
            self.dir_path[name] = path


        # utils
        qry  = "select name, value from parameter"
        rows = search_db (cursor, qry, verbose=False)
        if (not rows):
            print "no dir_path info in %s" % self.cfg_db_name
            cursor.close()
            db.close()
            sys.exit (1)
        for row in rows:
            [name, value]        = row
            if value.isdigit():
                value= int(value)
            else:
                try: 
                    value = float(value)
                except:
                    pass
            self.parameter_value[name] = value

        cursor.close()
        db.close()
コード例 #4
0
ファイル: tree.py プロジェクト: ivanamihalek/exolocator
    tree   = Tree()
    for species in all_species:
        leaf = Node(species)
        tree.leafs.append(leaf)
        if leaf.name == qry_species:
            qry_leaf = leaf

    tree.build(cursor)
    #find cousins for the qry leaf (recursively)
    cousins = find_cousins (qry_leaf) 
    
    return [qry_species]+cousins



#####################################        
if __name__ == '__main__':
    
    local_db = False
    db = connect_to_mysql()
    cursor = db.cursor()

    [all_species, ensembl_db_name] = get_species (cursor)

    tree   = Tree()
    for species in all_species:
        tree.add(cursor, species)
    tree.build(cursor)

    print tree.nhx_string()