Пример #1
0
def filter_seq(seq):
    """Examines unreserved sequences to see if they are prone to mutation. This
     currently ignores solely-power-of-2 guides with b > 3"""
    if seq.res:
        return None
    n = nt.Factors(seq.factors)
    guide, s, t = aq.canonical_form(n)
    seq.guide = guide
    # The target_tau for the composite is at most the class minus extant prime factor count
    cls = aq.get_class(guide=guide)
    num_larges = seq.factors.count("P")
    upper_bound_tau = cls - num_larges - len(t)

    if cls < 2 or upper_bound_tau < 2:  # Cheap tests to eliminate almost all sequences
        return None

    # Next we ignore sequences whose guide is solely a power of 2 greater than 3
    v = nt.Factors({p: a for p, a in guide.items() if p != 2 and a > 0})
    if int(v) == 1 and cls > 3:
        return None
    # This condition greatly reduces fdb load, but excludes a lot of sequences
    if not aq.is_driver(guide=guide):
        return None

    return n, guide
Пример #2
0
def examine_seq(id, forms=None, n=None, guide=None, seq=None):
    """Query the FDB by ID to analyze if the corresponding number may mutate by assuming
     the composite is of the given `forms`, where `forms` is a list of `form`s as used by
     the mfaliquot.aliquot.composite_tau_lte function. The optional n and guide arguments
     are for error checking purposes."""
    primes, comps = get_id_info(id)
    if len(comps) == 0:
        return None  # json data for this seq is out of date
    if len(comps) > 1 or list(comps.values()) != [1]:
        raise ValueError("Wtf?!? two composites or composite to a power? seq {}, id {}".format(seq.seq, seq.id))
    c = int(list(comps.keys())[0])
    guideprime, s, t = aq.canonical_form(primes)

    # We do a cross check that the fdb and data file agree: to do this,
    # we cut primes >9 digits from the fdb data
    nprime = {p: a for p, a in primes.items() if len(str(p)) <= 9}
    if (n is not None and nprime != n) or (guide is not None and guideprime != guide):
        # raise ValueError("Disagreement between local file and fdb: {} {}".format(n, nprime))
        print("Weird! Seq {} apparently is bad info in the data file.".format(seq.seq if seq else None))
        return None

    return aq.mutation_possible(primes, c, forms)