Beispiel #1
0
def vimstamp_open_file():
    path = vim.bindeval("resolve(expand(\'%\'))").decode("utf-8")
    ts = get_time_stamp(path)
    s = simplify(vim.current.buffer)

    vim.vars["g:vimstamp_idx2stamp"][str(
        vim.current.window.buffer.number)] = (s, ts, path)
Beispiel #2
0
def vimstamp_write_file():

    if str(vim.current.window.buffer.number
           ) not in vim.vars["g:vimstamp_idx2stamp"]:
        return

    s, ts, path = vim.vars["g:vimstamp_idx2stamp"][str(
        vim.current.window.buffer.number)]

    s_new = simplify(vim.current.buffer)
    ts_new = get_time_stamp(path)

    if s_new == s and ts != ts_new:
        set_time_stamp(path, ts)
        vim.command("e")
# Not
Not(V("X"))     # Negacija spremenljivke.
Not(a1)     # Negacija izraza.

print "::: END OPERANDI :::\n\n"
"""
######################################################
#################Simplify#############################
######################################################
"""
from simplify import *

print "::: BEGIN SIMPLIFY :::"
# Nekaj osnovnih primerov uporabe.
print simplify(Not(Not(a2)))    # Brise dvojne negacije.
print simplify(Or([V("X"), Not(V("X"))]))   # Prepozna tavtologijo.
print simplify(And([V("X"), Not(V("X"))]))
print simplify(And([V("X"), Tru()]))    # Pobrise nepotrebne spremenljivke.
print simplify(And([V("X"), V("X"), V("Y")]))   # Spremenljivke.
print simplify(And([V("X"), V("X"), V("Y"), Fls()]))
print simplify(Or([Or([V("X"), V("Y")]), Or([V("Y"), V("Z")])]))
print simplify(Not(And([V("X"), V("Y")])))  # Potisnemo negacijo navznoter.
# Razbije izraz na konjunkcije in disjunkcije ter potisne negacijo navznoter.
print simplify(Not(Equiv(V("X"), V("Y"))))

print "::: END SIMPLIFY :::\n\n"
"""
######################################################
#################SAT PREVEDBE#########################
######################################################
        flags = {}
        for an_id in poly_points.keys():
            yr,mn,dy =[ int(i) for i in startdates[an_id].split("-") ]
            if yr != 2018:
                continue
            elif mn < 5:
                continue
            elif mn == 5 and dy < 25:
                continue
            elif mn == 8 and dy > 16:
                continue
            elif mn > 8:
                continue
            #Simplify geometries
            #print(simplify(poly_points[an_id], 0.3, True))
            poly_points[an_id] = [[l['x'], l['y']] for l in simplify(poly_points[an_id], 0.01, True)]
            for f in data["features"]:
                if f["geometry"]["coordinates"] == poly_points[an_id]:
                    flags[an_id] = True
                    break
            if an_id not in flags.keys():
                data["features"].append({"type": "Feature",
                    "properties": { "id": "null"},
                    "geometry": { "type": "LineString", "coordinates": poly_points[an_id] }})
        with open('strava.geojson', 'w') as fp:
            json.dump(data, fp)

        # Write out that we have processed this CSV file so that
        # on next run, we do not have it repeat process.
        f = open(os.path.join(csv_dir, "processed.txt"), 'a')
        f.write(a_csv)
Beispiel #5
0
def assemble(reads, k, tour_bus_args, low_coverage_cutoff, outfile, write_intermediate):
	print "construct kmers"
	kmers = make_kmers(reads, k)

	print "construct graph"
	G = construct_de_bruijn_velvet(kmers, "False", '')
	if write_intermediate:
		nx.write_gexf(G, 'initial_graph.gexf')

	print "simplify"
	simplify(G, False)
	if write_intermediate:
		nx.write_gexf(G, 'after_simplify_1.gexf')

	print "remove tips"
	remove_tips(G, k)

	print "simplify"
	simplify(G, False)
	if write_intermediate:
		nx.write_gexf(G, 'after_simplify_2.gexf')

	print "resolve repeats"
	resolve_repeats(G)

	print "tour bus"
	run_tour_bus(G, tour_bus_args[0],tour_bus_args[1])
	if write_intermediate:
		nx.write_gexf(G, 'after_tour_bus.gexf')

	print "simplify"
	simplify(G, False)
	if write_intermediate:
		nx.write_gexf(G, 'after_simplify_3.gexf')

	print 'assemble_paths'
	assemble_paths(G, 3)
	if write_intermediate:
		nx.write_gexf(G, 'after_assemble_paths.gexf')

	print "remove low coverage nodes"
	remove_low_coverage(G, low_coverage_cutoff, 2*k)
	if write_intermediate:
		nx.write_gexf(G, 'final_graph.gexf')

	contig_length = [len(a) for a in G.nodes()]
	mean_contig = float(sum(contig_length)) / len(G.nodes())

	### information about assembly 
	print " "
	print " ***  ASSEMBLY INFORMATION  *** "
	print "number of contigs: " + str(len(G.nodes()))
	print "contig lengths: " + str(contig_length)
	print "max contig length: " + str(max(contig_length))
	print "mean contig length: " + str(mean_contig)

	of = open(outfile, 'w')
	for node in G.nodes():
		of.write(node+ '\n')

	return G.nodes()
def expr_simplify_to_the_same_old(tester, s_expr1, s_expr2):
	expr1 = string_to_expr.expression_from_string(s_expr1)
	expr2 = string_to_expr.expression_from_string(s_expr2)
	expr1 = simplify(expr1, pow_rules.pow_rules+trig_rules.trig_rules, [simplify_expr], m2)
	expr2 = simplify(expr2, pow_rules.pow_rules+trig_rules.trig_rules, [simplify_expr], m2)
	tester.assertEqual(expr1, expr2)
Beispiel #7
0
from parser import parse
from derive import *
from simplify import *

while 1:
    try:
        s = raw_input( 'pyderive > ' )
    except EOFError:
        break
    # print( simplify( parse( s ) ) )
    print( simplify( derive( parse( s ), 'x' ) ) )
Beispiel #8
0
from rules import RULES_CNF, DISTRIB_DNF, DISTRIB_CNF
from simplify import *
from unify import unify_functions
from pprint import pprint

# print(qmc.execute(4, *[0, 3, 5, 6, 7, 9, 12, 13, 15]))
# exit()
# print(simplify(_("TRUE | x")))
# print(simplify(_("((P & Q) & !R) | (P & !(Q | R))")))
# print(find_unifications(_("p(X,Y,Z)"), _("p(Y,Z,X)"), True))
# print([str(apply_subs(x, {
#     _("Y"): _("f(a)"),
#     _("Z"): _("g(a)"),
#     _("X"): _("a")
# })) for x in (_("p(h(Y,Z),f(a),g(a))"), _("p(h(f(X),g(X)),Y,Z)"))])
print(simplify(_("TRUE & x & y")))
#print(simplify(_("P(A) & !P(A) & C")))
#exit()
forms = {
    "!!A": "A",
    "TRUE & x & y": "x & y",
    "P(A) & !P(A) & C": "FALSE",
    "TRUE | x": "TRUE",
    "FALSE & x": "FALSE",
    "!!!!A": "A",
    "A & !A": "FALSE",
    "A & !B": "A & !B",
    "!(a|b)": "!a & !b",
    "b & y => y": "TRUE",
    "((P & Q) & !R) | (P & !(Q | R))": "P & !R",
    "(!Q & !R) | (Q & !R)": "!R",
Beispiel #9
0
def assemble(reads, k, tour_bus_args, low_coverage_cutoff, outfile,
             write_intermediate):
    print "construct kmers"
    kmers = make_kmers(reads, k)

    print "construct graph"
    G = construct_de_bruijn_velvet(kmers, "False", '')
    if write_intermediate:
        nx.write_gexf(G, 'initial_graph.gexf')

    print "simplify"
    simplify(G, False)
    if write_intermediate:
        nx.write_gexf(G, 'after_simplify_1.gexf')

    print "remove tips"
    remove_tips(G, k)

    print "simplify"
    simplify(G, False)
    if write_intermediate:
        nx.write_gexf(G, 'after_simplify_2.gexf')

    print "resolve repeats"
    resolve_repeats(G)

    print "tour bus"
    run_tour_bus(G, tour_bus_args[0], tour_bus_args[1])
    if write_intermediate:
        nx.write_gexf(G, 'after_tour_bus.gexf')

    print "simplify"
    simplify(G, False)
    if write_intermediate:
        nx.write_gexf(G, 'after_simplify_3.gexf')

    print 'assemble_paths'
    assemble_paths(G, 3)
    if write_intermediate:
        nx.write_gexf(G, 'after_assemble_paths.gexf')

    print "remove low coverage nodes"
    remove_low_coverage(G, low_coverage_cutoff, 2 * k)
    if write_intermediate:
        nx.write_gexf(G, 'final_graph.gexf')

    contig_length = [len(a) for a in G.nodes()]
    mean_contig = float(sum(contig_length)) / len(G.nodes())

    ### information about assembly
    print " "
    print " ***  ASSEMBLY INFORMATION  *** "
    print "number of contigs: " + str(len(G.nodes()))
    print "contig lengths: " + str(contig_length)
    print "max contig length: " + str(max(contig_length))
    print "mean contig length: " + str(mean_contig)

    of = open(outfile, 'w')
    for node in G.nodes():
        of.write(node + '\n')

    return G.nodes()