- /net/fugu/usr0/tools/pylib/-- This is what goes on the python path.
- /algo -- Code to perform general computational algorithms (see below)
- UnionFind -- module to execute UnionFind on set, based on CLR
- /Graph -- Graph algorithms
- UndirectedGraph -- Graph object with algorithms taking advantage of edge symmetry. (deprecated)
- DirectedGraph -- Graph object with graph algorithms based on CLR
- /BLAST -- Code wrapping common BLAST functions
- __init__.py -- Contains BLAST constants and command line formatting
- DB -- DBProfile class definition, code wrapping formatdb
- Results -- Alignment class for alignment data, Results class for parsing BLAST output
- /CDART -- Code wrapping CDART database objects (incomplete)
- PssmHit -- Represents object in "hits" table (incomplete)
- /DurandLab -- Code specific to our computing environment or DurandLab database
- __init__.py -- Constants and functions (pushConn, popConn) for connecting to database (currently motif), and determining paths usable throughout the lab
- ProteinSequence -- Contains ProteinSequence class, representing entries in DurandLab.prot_seq table and provides format translations
- ProteinSequenceSet -- Contains ProteinSequenceSet class, representing sets of entries defined in DurandLab.prot_seq_sets and DurandLab.prot_seq_set_membership
- ProteinArchitecture -- Code for discerning domain architecture based on CDART data (experimental)
- /ensembl -- Functions for retrieving information from ensembl's public MySQL server.
- /FASTA -- Functions for parsing FASTA files
- FastaSeq -- Contains FastaSeq object representing one sequence and header
- FastaFile -- Contains File-like object FastaFile for parsing entire file
- /SwissProt -- Contains SwissProt object for wrapping SwissProt DB entry and SwissProtFile object for parsing SwissProt flatfiles.
- /util -- general purpose code utilities
- arg_stream -- useful for creating files that read parameters from cmd line or stdin
- distinct -- removes duplicates from a list
- exec_cmd -- runs commands locally or remotely and returns result
- list2dict -- turns 2 lists to a dictionary
- Dummy -- empty class that you can assign attributes to
- eof -- determines if a file has reached end
- histogram -- divides list into buckets and counts (deprecated, will be improved)
- TablePrinter -- Prints columned output
help([module]). A "man" style interface will describe purpose and function of the libraries.
man rcs. In general, you must keep a seperate RCS subdirectory as a repository for each directory you want to version-control.
__init__.py in the directory. This will be the module itself, the code executed when the module is imported. Any other files placed in the directory will be submodules which can be imported explicitly.
import [module] makes the object or function (functions are objects!) available to a program as module.object.
from [module] import [resource] puts an object or function directly into the current namespace.
from ... import call to make that resource available in a standard way earlier in the module tree. Then users can use the standard interface and won't accidentally screw up their namespace.
import DurandLab
db = DurandLab.getConn(dbName = 'DurandLab')
db_auth = 0
c = db.cursor()
def authenticate(uname, passwd) :
global db, c, db_auth
db.change_user(uname, passwd)
db.select_db('DurandLab')
c = db.cursor()
db_auth = 1
|
As you can see, the DurandLab module wraps the database connection to make changing our db config easier. A single db object is initialized for the whole module as a global variable, and a cursor is created. The authenticate() function allows the user to input a username and password to gain write access if they are calling functions which require write access. Any functions that do require such should check the db_auth variable and throw an error if it's not on. Finally, if your functions call another function that requires authentication, make sure your authenticate function authenticates that module as well!!