Example #1
0
    def __init__(self,
                 db=None,
                 tempfilepath=None,
                 pathtoblast=None,
                 pathtocddDatabase=None,
                 PhageIDs=None):
        #password = getpass.getpass()
        self.username = raw_input("Database Username: "******"Database Password: "******"Database Server: ")
        self.database = raw_input("Database Name: ")
        print 'using databse: %s' % self.database
        self.c = db_conf(username=self.username,
                         password=self.password,
                         server=self.server,
                         db=self.database).get_cursor()
        if not PhageIDs:
            PhageIDs = phamerator_manage_db.get_PhageIDs(self.c)
        self.PhageIDs = list(PhageIDs)
        #errorHandler = pham.errorHandler()
        self.dbase = pham.db(self.c)

        if pathtocddDatabase == None:
            self.rpsblast_db = os.path.join(os.environ['HOME'], 'Databases',
                                            'Cdd', 'Cdd')
        else:
            self.rpsblast_db = pathtocddDatabase

        if tempfilepath == None:
            self.query_filename = "/tmp/query.fasta"
        else:
            self.query_filename = tempfilepath

        if pathtoblast == None:
            try:
                import ConfigParser
                cfg = ConfigParser.RawConfigParser()
                cfg.read(
                    os.path.join(os.environ['HOME'], '.phamerator',
                                 'phamerator.conf'))
                blast_dir = cfg.get('Phamerator', 'BLAST_dir')
                self.rpsblast_exe = os.path.join(blast_dir, 'bin', 'rpsblast')
                print 'path to rpsblast: %s' % self.rpsblast_exe

            except:
                print "BLAST not found, Exiting"
                sys.exit()

        else:
            self.rpsblast_exe = pathtoblast
Example #2
0
def main():
    cfg = ConfigParser.RawConfigParser()
    cfg.read(os.path.join(os.environ['HOME'], '.my.cnf'))
    import sys
    db = sys.argv[1]
    try:
        username = cfg.get('client', 'user')
    except ConfigParser.NoOptionError:
        username = raw_input('database username: '******'client', 'password')
    except ConfigParser.NoOptionError:
        import getpass
        password = getpass.getpass('database password: '******'root', password=password, server='localhost',
                db=db).get_cursor()
    phams = get_all_pham_names(c)
    for phamName in phams:
        print phamName
        phamMembers = get_pham_members(c, phamName)
        #for phamMember in phamMembers:
        #  relatives = [phamMember]
        #  #relatives = get_all_relatives(c, phamMember)
        #  #print 'seed: %s' % phamMember
        #  relatives = list(set(relatives) | set(follow_rel_chain2(c, phamMember, relatives)))
        phamMember = phamMembers[0]
        relatives = [phamMember]
        #  #relatives = get_all_relatives(c, phamMember)
        #  #print 'seed: %s' % phamMember
        relatives = list(
            set(relatives) | set(
                follow_rel_chain2(c,
                                  phamMember,
                                  relatives,
                                  cthreshold=0.325,
                                  bthreshold=1e-50)))

        phamMembers.sort()
        relatives.sort()
        if relatives != phamMembers:
            print '%s cannot account for all genes in pham %s' % (phamMember,
                                                                  phamName)
            print 'relatives: %s\nphamMembers: %s' % (relatives, phamMembers)
            print '%s : %s : %s' % (phamName, phamMembers, relatives)
            print 'mercifully exiting after one mismatch'
            sys.exit()
    print '%s database is OK' % db
def main():
  cfg = ConfigParser.RawConfigParser()
  cfg.read(os.path.join(os.environ['HOME'], '.my.cnf'))
  import sys
  db = sys.argv[1]
  try:
    username = cfg.get('client','user')
  except ConfigParser.NoOptionError:
    username = raw_input('database username: '******'client','password')
  except ConfigParser.NoOptionError:
    import getpass
    password = getpass.getpass('database password: '******'root', password=password, server='localhost', db=db).get_cursor()
  phams = get_all_pham_names(c)
  for phamName in phams:
    print phamName
    phamMembers = get_pham_members(c, phamName)
    #for phamMember in phamMembers:
    #  relatives = [phamMember]
    #  #relatives = get_all_relatives(c, phamMember)
    #  #print 'seed: %s' % phamMember
    #  relatives = list(set(relatives) | set(follow_rel_chain2(c, phamMember, relatives)))
    phamMember = phamMembers[0]
    relatives = [phamMember]
    #  #relatives = get_all_relatives(c, phamMember)
    #  #print 'seed: %s' % phamMember
    relatives = list(set(relatives) | set(follow_rel_chain2(c, phamMember, relatives, cthreshold=0.325, bthreshold=1e-50)))


    phamMembers.sort()
    relatives.sort()
    if relatives != phamMembers:
      print '%s cannot account for all genes in pham %s' % (phamMember, phamName)
      print 'relatives: %s\nphamMembers: %s' % (relatives, phamMembers)
      print '%s : %s : %s' % (phamName, phamMembers, relatives)
      print 'mercifully exiting after one mismatch'
      sys.exit()
  print '%s database is OK' % db
  def __init__(self,db=None,tempfilepath=None,pathtoblast=None,pathtocddDatabase=None,PhageIDs=None):
    #password = getpass.getpass()
    self.username = raw_input("Database Username: "******"Database Password: "******"Database Server: ")
    self.database = raw_input("Database Name: ")
    print 'using databse: %s' % self.database
    self.c = db_conf(username=self.username,password=self.password,server=self.server,db=self.database).get_cursor()
    if not PhageIDs:
      PhageIDs = phamerator_manage_db.get_PhageIDs(self.c)
    self.PhageIDs = list(PhageIDs)
    #errorHandler = pham.errorHandler()
    self.dbase = pham.db(self.c)

    if pathtocddDatabase == None:
      self.rpsblast_db = os.path.join(os.environ['HOME'], 'Databases', 'Cdd', 'Cdd')
    else:
      self.rpsblast_db = pathtocddDatabase

    if tempfilepath == None:
      self.query_filename = "/tmp/query.fasta"
    else:
      self.query_filename = tempfilepath


    if pathtoblast == None:
      try:
        import ConfigParser
        cfg = ConfigParser.RawConfigParser()
        cfg.read(os.path.join(os.environ['HOME'], '.phamerator', 'phamerator.conf'))
        blast_dir = cfg.get('Phamerator','BLAST_dir')
        self.rpsblast_exe = os.path.join(blast_dir,'bin','rpsblast')
        print 'path to rpsblast: %s' % self.rpsblast_exe

      except:
        print "BLAST not found, Exiting"
        sys.exit()

    else:
      self.rpsblast_exe = pathtoblast
def main():
  cfg = ConfigParser.RawConfigParser()
  cfg.read(os.path.join(os.environ['HOME'], '.my.cnf'))
  import sys
  db = sys.argv[1]
  try:
    username = cfg.get('client','user')
  except ConfigParser.NoOptionError:
    username = raw_input('database username: '******'client','password')
  except ConfigParser.NoOptionError:
    import getpass
    password = getpass.getpass('database password: '******'root', password=password, server='localhost', db=db).get_cursor()
  finals = get_finals(c)
  print 'finals:', finals
  drafts = get_drafts(c)
  print 'drafts:', drafts

  print 'removing the following phages:\n'
  remove_drafts(c, drafts, finals)
def main():
    cfg = ConfigParser.RawConfigParser()
    cfg.read(os.path.join(os.environ['HOME'], '.my.cnf'))
    import sys
    db = sys.argv[1]
    try:
        username = cfg.get('client', 'user')
    except ConfigParser.NoOptionError:
        username = raw_input('database username: '******'client', 'password')
    except ConfigParser.NoOptionError:
        import getpass
        password = getpass.getpass('database password: '******'root', password=password, server='localhost',
                db=db).get_cursor()
    finals = get_finals(c)
    print 'finals:', finals
    drafts = get_drafts(c)
    print 'drafts:', drafts

    print 'removing the following phages:\n'
    remove_drafts(c, drafts, finals)
Example #7
0
#!/usr/bin/env python

from phamerator import *
from phamerator.phamerator_manage_db import *
from phamerator.db_conf import db_conf
import sys, getpass

GeneID = sys.argv[1]
password = getpass.getpass()
db = raw_input('database: ')

c = db_conf(username='******', password=password, server='134.126.132.72', db=db).get_cursor()

print get_relatives(c, GeneID, alignmentType='both', clustalwThreshold=0.275, blastThreshold=0.0001)