Ejemplo n.º 1
0
# Prepare a FeatureSet
fs = FeatureSet("simple quantification")
fs.add(hydropathy_average_feat)
fs.add(charge_sum_abs_feat)
fs.add(volume_levels_feat)

# And use it to quantify protein sequence(s):
result_seq = fs(alphasyn_seq)
print result_seq
for seq in result_seq:
    print seq

# Plain functions operating on list also work:
print Feature(len)(alphasyn_seq[0])

# Calculate the hydropathy profile smoothed over the window of length 3
hydropathy_win3_feat = Feature(get_aa2hydropathy()).then(average, window=3)
print hydropathy_win3_feat(alphasyn_seq[0])

# Buggy version of the code above:
hydropathy_feat = Feature(get_aa2hydropathy())
hydropathy_win3_feat = hydropathy_feat.then(average, window=3)
print hydropathy_feat(alphasyn_seq[0])
print hydropathy_win3_feat(alphasyn_seq[0])

# Compact multiple single-value features
compact_seq = compact(result_seq)
for seq in compact_seq:
    print seq
Ejemplo n.º 2
0
        aa_mapping2 = get_aaindex_www(args.property2)
    try:
        aa_mapping2.default = float(args.default2)
    except (TypeError, ValueError):
        aa_mapping2.default = args.default2

    feat2 = Feature(aa_mapping2)
else:
    feat2 = Feature(identity)


# Make features based on mappings:
# feature1
if args.quantify1 in ['rec', 'det', 'pal', 'ratio_det', 'ratio_pal']:
    feat1 = feat1.then(quantify_method[args.quantify1],
                       metric=args.metric1, radius=float(args.radius1),
                       dim=int(args.dim1), tau=int(args.tau1),
                       det_len=int(args.diaglen1), pal_len=int(args.diaglen1))
else:
    feat1 = feat1.then(quantify_method[args.quantify1])
# feature2
if args.quantify2 in ['rec', 'det', 'pal', 'ratio_det', 'ratio_pal']:
    feat2 = feat2.then(quantify_method[args.quantify2],
                       metric=args.metric2, radius=float(args.radius2),
                       dim=int(args.dim2), tau=int(args.tau2),
                       det_len=int(args.diaglen2), pal_len=int(args.diaglen2))
else:
    feat2 = feat2.then(quantify_method[args.quantify2])

# Add the features to a FeatureSet
fs = FeatureSet("fs")
fs.add(feat1)
Ejemplo n.º 3
0
        'sum': sum,
        'sum_abs': sum_absolute,
        'avg': average,
        'avg_abs': average_absolute,
        'rec': recurrence,
        'det': determinism,
        'pal': palindromism,
        'ratio_det': ratio_determinism,
        'ratio_pal': ratio_palindromism,
        'entropy': entropy,
    }
    if args.quantify in ['rec', 'det', 'pal', 'ratio_det', 'ratio_pal']:
        feat = feat.then(quantify_method[args.quantify],
                         window=int(args.window),
                         metric=args.metric,
                         radius=float(args.radius),
                         dim=int(args.dim),
                         tau=int(args.tau),
                         det_len=int(args.diaglen),
                         pal_len=int(args.diaglen))
    else:
        feat = feat.then(quantify_method[args.quantify],
                         window=int(args.window))

# Add the Feature to a FeatureSet
fs = FeatureSet("fs")
fs.add(feat)

# And use it to convert the input set
conv_seq = fs(input_seq)

# Finally write to the 'output' file