Example #1
0
 def readAnnotatedTargets(self,targetFile,model,annotationName,regex,bNames = False,orderGenes = False):
     parser = FlatFileParser()
     modelFactory = ModelFactory()
     modelFactory.orderGenes = orderGenes
     report = parser.parseToReport(targetFile, "Row Names", header=["Control","Flux","Reaction Control","Flux Changes"])
     controlValues = report.getColumn("Control")
     if bNames:
         controlValues = self._deannotateGenes(controlValues, model, annotationName, regex)
     if self.orderGenes:
         controlValues = modelFactory.refactorStringMap(controlValues, sep="_")
     controlScore = report.getColumn("Flux")
     if bNames:
         controlScore =  self._deannotateGenes(controlScore, model, annotationName, regex)
     
     return(controlValues,controlScore)    
def loadControlTable(fileName,keyTag="Row Names",controlTag="control values",productionTag = "production"):
    '''
    Load flat file of control designs and production values
    '''
    
    if not os.path.exists(fileName):
        print "file name not found %s" % (fileName)
        return ([],None)
        
    header = [keyTag,controlTag,productionTag]
    parser = FlatFileParser()
    report = parser.parseToReport(fileName, keyTag=keyTag, header=header)
    result = []
    for rowName in report.returnRowNames():
        controlMapString = report.get(rowName, controlTag)
        controlMap = eval(controlMapString)
        production = report.get(rowName, productionTag)
        controlMapValue = (controlMap,production)
        result.append(controlMapValue)
    return (result,report)
def loadTargetTable(fileName,keyTag="Row Names",controlTag="control values"):
    '''
    Load flat file of control targets
    '''
    if not os.path.exists(fileName):
        #print "file name not found %s" % (fileName)
        return ({},None)
    else:
        pass
        #print "parsing %s" % (fileName)
    
    header = [keyTag,controlTag]
    parser = FlatFileParser()
    report = parser.parseToReport(fileName, keyTag=keyTag, header=header)
    controlMap = {}
    for rowName in report.returnRowNames():
        keyName= rowName
        controlValue = report.get(rowName, controlTag)
        controlMap[keyName] = controlValue
    
    return (controlMap,report)
def parseUserTargets(controlFile,model):
    parser = FlatFileParser()
    gtMap = model.getGeneTargetMap()
    report = parser.parseToReport(controlFile, "GeneName", header=["GeneName","library","prefix","bnumber","value"])
    rowNames = report.returnRowNames()
    controlNames = []
    controlIds = set()
    controlLibrariesMap = {}
    
    for rowName in rowNames:

        libName = report.getElement(rowName, "library")
        prefix = report.getElement(rowName, "prefix")
        geneID = report.getElement(rowName, "bnumber")
        value = report.getElement(rowName, "value")
        
        rxnControlMap = {}
        geneID = geneID.replace(" ","_")
        if geneID not in gtMap.keys():
            continue
        for rxn in gtMap[geneID]:
            rxnControlMap[rxn] = value
        
        controlID = (libName,prefix,geneID)
        
        controlNames.append(geneID)
        controlIds.add(controlID)
    
        if (libName,prefix) not in controlLibrariesMap.keys():
                controlLibrariesMap[(libName,prefix)] = {}
        controlLibrariesMap[(libName,prefix)].update(rxnControlMap)
    
    controlLibraries =[]
    for (key,value) in controlLibrariesMap.items():
        (libName,prefix) = key
        controlLibraries.append((libName,prefix,value))
    
    return (controlNames,controlIds,controlLibraries)
Example #5
0
    #------------------------
    
    targetTag = "([^ACGTacgt]+.*[^ACGTacgt]+)"
    boundary = options.flankingSize
    #boundary = 45
    searchSize = 200
    cutOff = (None,-13.0)
    primerSize = 20
    primerTm = 58
    primerDistance = 250
    
    #--------------------------
    #Start factories
    #--------------------------
    
    fileParser = FlatFileParser()
    seqTools = SequenceTools()
    seqTools.verbose = verbose
    seqFac = SequenceFactory()
    seqFac.verbose = verbose
    recFac = RecombinationOligoFactory()
    recFac.verbose = verbose
    
    oligoRecords = None
    gRecord = None

    #----------------------------------
    # Generate new oligos from targets
    #----------------------------------
    
    if mode == "location" or (locationFile != '' and mode == "auto"):