Exemplo n.º 1
0
def getNextSeq(seqname):
    """
    Return the next value from a database sequence given the sequence name
    
    @param seqname: Name of sequence
    @type seqname: str
    @return: the next value from the database sequence
    @rtype: int
    """
    return DBSession.execute(text("select nextval(:seqname) as myseq"), { 'seqname' : seqname}).fetchone()['myseq']
Exemplo n.º 2
0
def generateMolRegId(prefixId):
    """
    Generate the next reg ID in a sequence for a molecule, given the prefix Id
    
    @param prefixId: The ID of the prefix used for the reg ID
    @type prefixId: int
    @return: generated reg ID
    @rtype: str 
    """
    log.debug('Retrieving mol_prefix_name for %d' % int(prefixId))
    prefix = DBSession.execute(text('select mol_prefix_name from mol_prefix where mol_prefix_id = :prefix_id'), { 'prefix_id' : prefixId}).fetchone()['mol_prefix_name']
    seq = getNextSeq('regseq_' + prefix)
    mol_reg_id = prefix + "-" + str(seq)
    log.debug('Generated mol registration ID of %s' % mol_reg_id)
    return mol_reg_id
Exemplo n.º 3
0
 def testCompareSmartsToMDL(self):
     """Can compare a SMARTS pattern to an MDL Mol string"""
     r=DBSession.execute(text("select chem.compareSmartsToMol('c', :molstr) as comp"), dict(molstr=self.molstr)).fetchone()
     ok_(r['comp'], 'SMARTS pattern failed to match MDL Mol string')
Exemplo n.º 4
0
 def testCompareSmartsToSmiles(self):
     """Can compare a SMARTS pattern to a SMILES string"""
     r=DBSession.execute(text("select chem.compareSmartsToSmiles('c', 'c1ccccc1') as comp")).fetchone()
     ok_(r['comp'], 'SMARTS pattern failed to match SMILES string')