Exemple #1
0
def fold_clusters(lock, cluster, seqs, otufolder):
    '''Function for multithreading.
    Computes structure for a cluster and writes it to file'''
    aln, struct = bayesfold(seqs, params={"-diags": True})
    gshape = get_shape(struct)
    #write structure out to file
    lock.acquire()
    cfo = open(otufolder + "cluster_structs.fasta", 'a')
    cfo.write(">" + cluster + " " + gshape + "\n" + struct + "\n")
    cfo.close()
    #print cluster + ": " + struct
    #stdout.flush()
    lock.release()
Exemple #2
0
def group_by_shape(shapedict, struct):
    '''Multithreading function
    Takes in shapedict manager dictionary and structure
    Fits structure's shape into dictionary or adds new shape'''
    try:
        famed = False
        #convert to shape
        gshape = get_shape(struct)
        for famshape in shapedict.keys():
            #loop over all previously found shapes, see if it fits
            if gshape == famshape:
                shapedict[gshape] += [struct]
                famed = True
                break
        #if not fitted, create new group for this shape
        if not famed:
            shapedict[gshape] = [struct]
    except Exception, e:
        print "ERROR:", str(e)
        stdout.flush()