Exemplo n.º 1
0
def main():
    if len(sys.argv) == 4:
        method = int(sys.argv[1])
        size = int(sys.argv[2])
        repeats = int(sys.argv[3])

    else:
        print(
            "syntax: python3 EvaluateCFRandom.py <method (int)> <size (int)> <repeats (int)>"
        )
        print("Methods: ")
        print("\t0 : dummy")
        print("\t1 : Mean Utility")
        print("\t2 : Weighted Sum")
        print("\t3 : Weighted nNN")
        print("\t4 : Average nNN")
        return

    #all parsing should be done here
    path = 'data/jester-data-1.csv'
    parsed = parser.Parse(path)

    #prep the output files
    out = open("out_method_1.csv", "w")
    csv_out = csv.writer(out, delimiter=',', quotechar='"')
    csv_out.writerow([
        'userId', 'itermID', 'Actual_Rating', 'Predicted_Rating',
        'Delta_Rating'
    ])

    for _ in range(repeats):
        evaluate(parsed, method, size, csv_out)
Exemplo n.º 2
0
def fetch_logs():
    p = parser.Parse()
    files = p.filenames("logs")
    logs = []
    for f in files:
        logs.extend(p.readfile("logs/" + f))
    return logs
Exemplo n.º 3
0
def simulate_agent(data):
    m = parser.Parse(data)
    print("Parsed message: {}".format(str(m)))
    print("ATK_VEC_{atk_vec} for {duration} seconds".format(**m._asdict()))
    for t in m.targets:
        print("TARGET: {IP}/{mask}".format(**t._asdict()))
    for o in m.options:
        print("OPTIONS: {var}={val}".format(**o._asdict()))
Exemplo n.º 4
0
def main():
    save, read = False, False
    if len(sys.argv) == 1:
        help()
        return
    if "--save" in sys.argv:
        save = True
    if "--read" in sys.argv or "-r" in sys.argv:
        read = True
    commands = [
        "-s", "--search", "--page", "-p", "-c", "--count", "-r", "--read"
    ]
    check()
    pars = parser.Parse(commands)
    args = pars.parse()
    bad = searcher.Search(args, save, read)
    bad.search()
Exemplo n.º 5
0
 def __ProcessReply(self, data):
     hex_data = haxorview(data)
     self.l.debug("{} bytes recv, hexdump:\n{}".format(len(data), hex_data))
     if len(data) < 4:
         self.stats['pong'] += 1
     else:
         self.stats['commands'] += 1
         try:
             m = parser.Parse(data)
             self.l.debug("Parsed message: {}".format(str(m)))
             self.l.warn("ATK_VEC_{m.atk_vec} for {m.duration} seconds"\
                 .format(m=m))
             for t in m.targets:
                 self.l.warn("TARGET: {t.IP}/{t.mask}".format(t=t))
             for o in m.options:
                 self.l.warn("OPTIONS: {o.var}={o.val}".format(o=o))
         except:
             self.l.error("Unable to parse:\n{}".format(hex_data))
    if l == []:
        return []
    if l[0][0] == lexer.T_NLN:
        return eraseFirstNln(l[1:])
    else:
        return l


ts1 = eraseFirstNln(
    list(filter((lambda x: x[0] != lexer.T_PREPROC),
                lexer.toTokens(s + '\n'))))

for i in ts1:
    print(i)

p1 = parser.fixTree(parser.Parse(ts1))

fout = open('/tmp/graph.dot', 'w')

fout.write('''graph tr {
''')
idx = 0


def drawTree(i, l, rodix):
    global idx
    thix = 'n' + str(idx)
    idx += 1
    if type(l) != list:
        fout.write(str(thix) + ' [label="' + str(l) + '"];')
        fout.write(str(rodix) + ' -- ' + str(thix) + ';')
Exemplo n.º 7
0
        strx = sys.argv[1]
    except:
        print "Usage: parser.py filename"
        exit(1)

    try:
        f = open(strx)
    except:
        print "file '" + strx + "' must be an existing and readble file."
        exit(2)

    try:
        buf = f.read()
    except:
        print "Cannot read'" + strx + "'"

    f.close()

    mainview = pangodisp.PangoView()
    #mainview.add_text("hello")

    xstack = stack.Stack()
    lexer.Lexer(buf, xstack, parser.tokens)
    #xstack.dump() # To show what the lexer did
    parser.Parse(buf, xstack)

    # Output results (to show workings)
    print _cummulate

    main()
Exemplo n.º 8
0
	else:
		print("Please enter the path to the mpileup file\nUsage: python scVILP_main.py -in <path to the mpileup file> -names <path to the list of cell names>")
		sys.exit()
	if args['missing data threshold']!=None:
		missing_data_threshold = float(args['missing data threshold'])
	if args['false positive rate']!=None:
		fp_given = float(args['false positive rate'])
	if args['false negative rate']!=None:
		fn_given = float(args['false negative rate'])
	if args['maximum number of violations']!=None:
		K_ = int(args['maximum number of violations'])


	##############################################################################
	########################### Parse the mpileup file ###########################
	(read_counts, alts, refs, chroms, positions, names, depths) = parser.Parse(cell_names_path, data_path)
	n=read_counts.shape[0]
	l=read_counts.shape[1]

	print("# of taxa: %d" % n)
	print("# of mutations: %d" % l)

	print("false positive rate given: %f" %fp_given)
	print("false negative rate given: %f" %fn_given)



	mat_ = optimize(read_count_mat=read_counts,fp=fp_given,fn=fn_given,missing_data_thr=missing_data_threshold, K_vios=K_, mu0=1e-3, mu1=0.5)

	#############################################################################
	#################### Generate heatmap of the genotypes ######################
Exemplo n.º 9
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This program illustrates how a JSOL program can be sent between applications.
# A fib function is created in the first Eval, and then sent to the second Eval
# to be run.

import jsol
import json
import parser

with open('examples/psol/part1.psol') as f:
    fib = jsol.Eval(parser.Parse(f.read())).json()

print 'JSOL created!:'
print json.dumps(fib, indent=3)
print 'Passing to other instance...'

with open('examples/psol/part2.psol') as f:
    jsol.Eval(parser.Parse(f.read()), argv=fib)