Package schrodinger :: Package application :: Package combiglide :: Package packages :: Module chutils :: Class JoiningRules
[hide private]
[frames] | no frames]

Class JoiningRules

Store joining rules read from a file and provide access methods.

Instance Methods [hide private]
 
__init__(self, source)
Read and store joining rules.
 
__eq__(self, other)
 
__ne__(self, other)
 
explainNe(self, other)
Explain why two rule sets differ; silent if they do not differ
 
readDb(self, source)
Read a joining-rules table from a DB.
 
writeDb(self, conn, cur, dbname='')
Write joining-rules tables into a DB with the specified connection and cursor object
 
readFile(self, fname=None)
Read the rules from a file, or stdin in fname is not specified.
 
checkRules(self)
Throw an exception if something is amiss
 
writeRules(self, fname=None, use_def_names=False)
Write the rules to a file, or to stdout if fname is not specified.
 
getDefNamesAll(self)
Return the list of definition names
 
getDefByName(self, name)
Return the SMARTS corresponding to this definition
 
getPatternsAll(self)
Return all match patterns that have been defined for any purpose
 
getPatternsOk(self)
Return all patterns that have SMARTS joining rules
 
getPatternsOkm(self)
Return all patterns that have disfavored SMARTS joining rules
 
getRulesOk(self)
Return all SMARTS joining rules allowed by patterns
 
getRulesOkm(self)
Return all SMARTS disfavored joining rules allowed by patterns
 
getPatternsOblig(self)
Return all patterns that encode obligate attachments
 
getOkRule(self, pattern)
Return allowed SMARTS for the specified pattern
 
getOkmRule(self, pattern)
Return disfavored SMARTS for the specified pattern
 
getOblig(self, pattern)
Return True if pattern has obligate attachment; else False
 
getOkPattern(self, rule)
Return all patterns for which this is an allowed SMARTS rule
 
getOkmPattern(self, rule)
Return all patterns for which this is a disfavored SMARTS rule
Static Methods [hide private]
 
getCreateSmartsRulesTableSql(dbname)
Return the sql for creating a smarts-rules table in the named db.
 
getCreateJoiningRulesTableSql(dbname)
Return the sql for creating a joining-rules table in the named db.
Method Details [hide private]

__init__(self, source)
(Constructor)

 

Read and store joining rules.  A JoiningRules object corresponds to a
 single joining-rules source, which can be a file or a Db, in
 the form of a ( conn, cur ) pair. If a source is not supplied,
 stdin is read as a file.
If an OK- pattern is found for which there is no OK pattern,
 a ValueError is raised. The list of offending patterns is
 retained in self.missing_ok_patterns.
source specifies where the rules are to be read from. If it is
 a character string, it must be a file name. Otherwise, it represents
 a database and must a sequence whose first two elements are the
 conn and cur for the database. The third element is optional and
 if specified is the database name.

readDb(self, source)

 

Read a joining-rules table from a DB. Source is a sequence containing a connection object and a cursor object as its first two elements and an optional database name as its third element. Assume that prior to creation of cur, "conn.row_factory = sqlite3.Row" has been called.

getCreateSmartsRulesTableSql(dbname)
Static Method

 

Return the sql for creating a smarts-rules table in the named db. This is put into a static method because the information it returns has to be accessed from places where no JoiningRules object exists.

getCreateJoiningRulesTableSql(dbname)
Static Method

 

Return the sql for creating a joining-rules table in the named db. This is put into a static method because the information it returns has to be accessed from places where no JoiningRules object exists.

writeRules(self, fname=None, use_def_names=False)

 

Write the rules to a file, or to stdout if fname is not specified. User-supplied definitions are always written out, but unless use_def_names is True, the SMARTS are written with the defintions expanded.