CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
caferror Namespace Reference

Functions

def errorOut
 Function Definitions. More...
 
def optParse
 
def printWrite
 
def cafeRun
 
def errFileCheck
 
def getScore
 
def maxfamsize
 

Variables

tuple startsec = time.time()
 Main Block. More...
 
tuple start = datetime.datetime.now()
 
string initCheck = ""
 
list spec_to_min = []
 
int rmlog = 0
 
int FilterFlag = 0
 
tuple inFile = open(inFilename, "r")
 
tuple inLines = inFile.readlines()
 
list CafePath = inLines[x]
 
list FamFile = inLines[x]
 
list Tree = inLines[x]
 
list LamStruct = inLines[x]
 
list t_struct = LamStruct[LamStruct.index("-t"):]
 
list treestring = Tree[Tree.index("("):]
 
 caferrorLog = tmpDir+caferrorLog;
 
tuple clogfile = open(caferrorLog, "w")
 
 outFilename = tmpDir+outFilename;
 
tuple outFile = open(outFilename, "w")
 
int pad = 35
 Begin input info block! More...
 
int numruns = 1
 End input info block! More...
 
 preScore = lastScore;
 
 preLam = lastLam;
 
list errList = []
 Global error estimation begins here for -c 0 (default) More...
 
 errMin = initError;
 
 minScore = lastScore;
 Global error estimation begins here for -c 1. More...
 
 lastError = initError;
 
float nextError = 0.0
 The main logic statements of the code are below. More...
 
float posLimit = 1.0
 
 posLimScore = lastScore;
 
float negLimit = 0.0
 
float negLimScore = 0.0
 
int currentError = initError/2
 if Mode == 1 or Mode == 3: overallMinScore = currentScore; Toggle this line to either keep the background constant (commented) or update it each time a species is minimized. More...
 
int tally = 0
 
int keepGoing = 1
 These are the termination scenarios. More...
 
 megLimScore = lastScore;
 
 minLam = currentLam;
 
 lastScore = currentScore;
 
dictionary finalSpecDict = {}
 Individual species error estimation begins here if -s 1. More...
 
 overallMinScore = minScore;
 
list moreErrSpec = []
 
 specMinScore = minScore;
 
 oldspecMin = minScore;
 
int zcheck = 0
 
int minimized = 0
 
 specMinErr = errMin;
 

if Mode == 1 or Mode == 3:

More...
 
string check = "higher than"
 
string check2 = "will not be further minimized."
 
tuple numrnuns = cafeRun(FamFile, Tree, LamStruct, CafePath, tmpDir, caferrorLog, finalSpecDict, spec_to_min, rmlog, FilterFlag, numruns, vOpt)
 The final CAFE run which generates a report with the minimized error. More...
 
tuple endsec = time.time()
 Main output block. More...
 
tuple runtime = (float(endsec) - float(startsec))
 
tuple end = datetime.datetime.now()
 

Function Documentation

def caferror.cafeRun (   families,
  newick,
  lamb,
  path,
  tempDir,
  cafLog,
  specDict,
  spectomin,
  logrm,
  fflag,
  nr,
  vb 
)
def caferror.errFileCheck (   errspec_check,
  errstring_check,
  specdict_check,
  thedir,
  cafLog 
)
def caferror.errorOut (   errnum,
  errmsg 
)

Function Definitions.

def caferror.getScore (   error,
  spectomin,
  tempDir,
  wout,
  cafLog 
)
def caferror.maxfamsize (   inFilename,
  totError,
  errFilename 
)
def caferror.optParse (   errorflag)
def caferror.printWrite (   o_name,
  v,
  o_line1,
  o_line2 = "",
  pad = 0 
)

Variable Documentation

list caferror.CafePath = inLines[x]
tuple caferror.caferrorLog = tmpDir+caferrorLog;
string caferror.check = "higher than"
string caferror.check2 = "will not be further minimized."
tuple caferror.clogfile = open(caferrorLog, "w")
float caferror.currentError = initError/2

if Mode == 1 or Mode == 3: overallMinScore = currentScore; Toggle this line to either keep the background constant (commented) or update it each time a species is minimized.

Toggle this line to either keep the background constant (commented) or update it each time a species is minimized.

tuple caferror.end = datetime.datetime.now()
tuple caferror.endsec = time.time()

Main output block.

list caferror.errList = []

Global error estimation begins here for -c 0 (default)

float caferror.errMin = initError;
list caferror.FamFile = inLines[x]
int caferror.FilterFlag = 0
dictionary caferror.finalSpecDict = {}

Individual species error estimation begins here if -s 1.

After the above algorithm has minimized error scores across all species (by applying the same error model to all species simultaneously), the user has the option to continue minimization for each individual species. This is done by iteratively adding and subtracting 10% of the global min error from each current species's error model until the score ceases to improve.

tuple caferror.inFile = open(inFilename, "r")
string caferror.initCheck = ""
tuple caferror.inLines = inFile.readlines()
int caferror.keepGoing = 1

These are the termination scenarios.

If the error parameter reaches a certain level of precision (12 decimal places), or if CAFE has been run 20 times, error estimation is terminated. This may be improved.

list caferror.LamStruct = inLines[x]
caferror.lastError = initError;
caferror.lastScore = currentScore;
caferror.megLimScore = lastScore;
int caferror.minimized = 0
caferror.minLam = currentLam;
tuple caferror.minScore = lastScore;

Global error estimation begins here for -c 1.

list caferror.moreErrSpec = []
int caferror.negLimit = 0.0
caferror.negLimScore = 0.0
tuple caferror.nextError = 0.0

The main logic statements of the code are below.

These take the score and error values of the most recent CAFE run and evaluate them against some information obtained from previous runs, eventually arriving at a point where the termination scenarios are met with a minimum score value.

tuple caferror.numrnuns = cafeRun(FamFile, Tree, LamStruct, CafePath, tmpDir, caferrorLog, finalSpecDict, spec_to_min, rmlog, FilterFlag, numruns, vOpt)

The final CAFE run which generates a report with the minimized error.

tuple caferror.numruns = 1

End input info block!

caferror.oldspecMin = minScore;
tuple caferror.outFile = open(outFilename, "w")
caferror.outFilename = tmpDir+outFilename;
caferror.overallMinScore = minScore;
int caferror.pad = 35

Begin input info block!

int caferror.posLimit = 1.0
caferror.posLimScore = lastScore;
caferror.preLam = lastLam;
caferror.preScore = lastScore;
int caferror.rmlog = 0
tuple caferror.runtime = (float(endsec) - float(startsec))
list caferror.spec_to_min = []
caferror.specMinErr = errMin;

if Mode == 1 or Mode == 3:

caferror.specMinScore = minScore;
tuple caferror.start = datetime.datetime.now()
tuple caferror.startsec = time.time()

Main Block.

list caferror.t_struct = LamStruct[LamStruct.index("-t"):]
int caferror.tally = 0
list caferror.Tree = inLines[x]
tuple caferror.treestring = Tree[Tree.index("("):]
int caferror.zcheck = 0