Example #1
0
    def readObjects(self, file):
        """Use the class specific read function to create darts base on reading them from file.

        file should be a handle to the file where darts are stored.
        """

        self._collection = readScores(file)
Example #2
0
def readScorePairs(scoresFN,geneNames,scoreType):
    '''Read through a scores file, and separate into all pairwise
comparisons. Return as dict.'''
    
    pairD = {}

    scoresO = scores.readScores(scoresFN,geneNames=None)
    
    for gn1,gn2 in scoresO.iterateEdgesByEndNodes():
        sc = scoresO.getScoreByEndNodes(gn1,gn2,scoreType)
        sp1 = geneNames.numToStrainName(gn1)
        sp2 = geneNames.numToStrainName(gn2)
        key = tuple(sorted([sp1,sp2]))
        
        if key in pairD:
            pairD[key].append(sc)
        else:
            pairD[key] = [sc]
        
    return pairD
Example #3
0
    paramD = parameters.loadParametersD(paramFN)

    ## load data structures we'll use below
    tree, strainStr2NumD, strainNum2StrD = trees.readTree(paramD['treeFN'])

    # an object for gene name conversions
    geneNames = genomes.geneNames(paramD['geneOrderFN'], strainStr2NumD,
                                  strainNum2StrD)

    subtreeL = trees.createSubtreeL(tree)
    subtreeL.sort()
    geneOrderT = genomes.createGeneOrderTs(paramD['geneOrderFN'], geneNames,
                                           subtreeL, strainStr2NumD)

    ## read scores
    scoresO = scores.readScores(paramD['scoresFN'], geneNames)

    ## make gene families
    familyIslandFormationSummaryF = open(
        paramD['familyIslandFormationSummaryFN'], 'w')
    familyL = families.families(
        tree, subtreeL, geneNames, scoresO, paramD['minNormThresh'],
        paramD['minCoreSynThresh'], paramD['minSynThresh'],
        paramD['synAdjustThresh'], paramD['synAdjustExtent'],
        paramD['familyFN'], strainNum2StrD, familyIslandFormationSummaryF)

    ## group gene families into islands
    islands.makeIslands(geneOrderT, geneNames, subtreeL, tree,
                        paramD['proxThreshL'], familyL, paramD['numThreads'],
                        strainStr2NumD, strainNum2StrD,
                        paramD['rootFocalClade'], paramD['islandOutFN'],
Example #4
0
import parameters,genbank,trees,genomes,scores,families,islands

## Does island making without family making (i.e. the second half of
## what xenoGI.py does).

if __name__ == "__main__":

    paramFN=sys.argv[1]
    paramD = parameters.loadParametersD(paramFN)

    ## load data structures we'll use below
    tree,strainStr2NumD,strainNum2StrD = trees.readTree(paramD['treeFN'])

    # an object for gene name conversions
    geneNames = genomes.geneNames(paramD['geneOrderFN'],strainStr2NumD,strainNum2StrD)

    subtreeL=trees.createSubtreeL(tree)
    subtreeL.sort()
    geneOrderT=genomes.createGeneOrderTs(paramD['geneOrderFN'],geneNames,subtreeL,strainStr2NumD)

    ## read scores
    scoresO = scores.readScores(paramD['scoresFN'],geneNames)

    ## load gene families
    familyL = families.readFamilies(paramD['familyFN'],tree,geneNames,strainStr2NumD)
    
    ## group gene families into islands
    outputSummaryF = open(paramD['outputSummaryFN'],'w')
    islands.makeIslands(geneOrderT,geneNames,subtreeL,tree,paramD['proxThreshL'],familyL,paramD['numThreads'],strainStr2NumD,strainNum2StrD,paramD['rootFocalClade'],paramD['islandOutFN'],outputSummaryF)
    outputSummaryF.close()
Example #5
0
results.append(test_score(maxHit, finish, standard, [0, 1, 2], file))
results.append(test_score(no_cigar, unusual, standard, [0, 1, 2], file))

#Reversed
print('Testing reversely sorted darts')
results.append(test_score(gutter, board, minHit, [2, 1, 0], file))
results.append(test_score(minHit, almost, unbiased, [2, 1, 0], file))
results.append(test_score(no_cigar, eyes, maxHit, [2, 1, 0], file))
results.append(test_score(minHit, unusual, maxHit, [2, 1, 0], file))
results.append(test_score(standard, finish, maxHit, [2, 1, 0], file))
results.append(test_score(standard, unusual, no_cigar, [2, 1, 0], file))

#Random order
print('Testing randomly ordered darts')
results.append(test_score(board, gutter, minHit, [1, 2, 0], file))
results.append(test_score(minHit, unbiased, almost, [2, 0, 1], file))
results.append(test_score(maxHit, no_cigar, eyes, [0, 2, 1], file))
results.append(test_score(maxHit, minHit, unusual, [0, 2, 1], file))
results.append(test_score(standard, maxHit, finish, [2, 0, 1], file))
results.append(test_score(unusual, no_cigar, standard, [1, 0, 2], file))

#Print summary
printTests(results)

#Load scores from file
file = open(FILENAME, 'r')
scores = readScores(file)

for s in scores:
    print(str(s))