示例#1
0
def downsample_elution(elution, downsample, seed=0):
    """
    Return a new elution with every downsample-th fraction.
    """
    down_elut = Struct()
    down_elut.__dict__ = elution.__dict__.copy()
    down_elut.mat = elution.mat[:,seed::2]
    down_elut.fractions = elution.fractions[::2]
    down_elut.name = elution.name + '_down%i' % downsample
    return(down_elut)
示例#2
0
def downsample_elution(elution, downsample, seed=0):
    """
    Return a new elution with every downsample-th fraction.
    """
    down_elut = Struct()
    down_elut.__dict__ = elution.__dict__.copy()
    down_elut.mat = elution.mat[:, seed::2]
    down_elut.fractions = elution.fractions[::2]
    down_elut.name = elution.name + "_down%i" % downsample
    return down_elut
示例#3
0
def subset_elution(elution, prot_set):
    """ 
    Return an elution only containing the proteins contained in the
    provided prot_set.
    """
    newel = Struct()
    newel.__dict__ = elution.__dict__.copy()
    prot_inds, newprots = zip(*[(i, p) for i, p in enumerate(elution.prots) if p in prot_set])
    newel.mat = elution.mat[prot_inds, :]
    newel.prots = newprots
    print len(newel.prots), "prots from", elution.filename, "in set"
    return newel
示例#4
0
def subset_elution(elution, prot_set):
    """ 
    Return an elution only containing the proteins contained in the
    provided prot_set.
    """
    newel = Struct()
    newel.__dict__ = elution.__dict__.copy()
    prot_inds, newprots = zip(*[(i,p) for i,p in enumerate(elution.prots) 
        if p in prot_set])
    newel.mat = elution.mat[prot_inds,:]
    newel.prots = newprots
    print len(newel.prots), 'prots from', elution.filename, 'in set'
    return newel
示例#5
0
def split_muliple_elutions(big_elut):
    """
    Split an elution into multiple based on use of _fraction_elutions.
    """
    elution_columns = _fraction_elutions(big_elut.fractions)
    eluts = {}
    for elution_name in elution_columns:
        new_elut = Struct()
        new_elut.__dict__ = big_elut.__dict__.copy()
        new_elut.mat = big_elut.mat[:,elution_columns[elution_name]]
        new_elut.fractions = list(np.array(big_elut.fractions)[elution_columns[elution_name]])
        new_elut.filename = big_elut.filename + '__' + elution_name
        eluts[elution_name] = new_elut
    return eluts
示例#6
0
def split_muliple_elutions(big_elut):
    """
    Split an elution into multiple based on use of _fraction_elutions.
    """
    elution_columns = _fraction_elutions(big_elut.fractions)
    eluts = {}
    for elution_name in elution_columns:
        new_elut = Struct()
        new_elut.__dict__ = big_elut.__dict__.copy()
        new_elut.mat = big_elut.mat[:, elution_columns[elution_name]]
        new_elut.fractions = list(np.array(big_elut.fractions)[elution_columns[elution_name]])
        new_elut.filename = big_elut.filename + "__" + elution_name
        eluts[elution_name] = new_elut
    return eluts
示例#7
0
def struct_copy(s):
    print "Warning: this may not actually copy group variables."
    newstruct = Struct()
    newstruct.__dict__ = s.__dict__.copy()
    return newstruct
示例#8
0
def struct_copy(s):
    print "Warning: this may not actually copy group variables."
    newstruct = Struct()
    newstruct.__dict__ = s.__dict__.copy()
    return newstruct
示例#9
0
def struct_copy(s):
    newstruct = Struct()
    newstruct.__dict__ = s.__dict__.copy()
    return newstruct