本文整理匯總了Python中Struct.Struct.fractions方法的典型用法代碼示例。如果您正苦於以下問題:Python Struct.fractions方法的具體用法?Python Struct.fractions怎麽用?Python Struct.fractions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Struct.Struct
的用法示例。
在下文中一共展示了Struct.fractions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: downsample_elution
# 需要導入模塊: from Struct import Struct [as 別名]
# 或者: from Struct.Struct import fractions [as 別名]
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: split_muliple_elutions
# 需要導入模塊: from Struct import Struct [as 別名]
# 或者: from Struct.Struct import fractions [as 別名]
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