示例#1
0
def generate_analysis(bmeg, path):
    file = open(path)
    lines = csv.DictReader(file, quotechar='"', delimiter='\t')
    samples = map(
        lambda line: line['gdc_cases.samples.portions.submitter_id'][:16],
        lines)

    O = ophion.Ophion(bmeg)

    def analyze(gene):
        errors = []
        results = []

        for sample in samples:
            print(sample)
            result = O.query().has("gid", ['biosample:' + sample]).incoming(
                "tumorSample").incoming("effectOf").outgoing("inGene").has(
                    "symbol", [gene]).count().execute()
            if 'error' in result:
                errors.append(sample)
            else:
                results.append(sample + "\t" + str(result['result'][0]))

        return results, errors

    return analyze
示例#2
0
def reverse_analysis(bmeg, path):
    file = open(path)
    lines = csv.DictReader(file, quotechar='"', delimiter='\t')
    samples = set(
        map(lambda line: line['gdc_cases.samples.portions.submitter_id'][:16],
            lines))

    O = ophion.Ophion(bmeg)

    def analyze(gene):
        results = O.query().has("gid", ["gene:" + gene]).incoming(
            "inGene").outgoing("effectOf").outgoing("tumorSample").execute()
        result_set = set(
            map(lambda result: result['properties']['barcode'][:16],
                results['result']))
        intersection = set.intersection(result_set, samples)

        print(len(intersection))

        return intersection, []

    return analyze
示例#3
0
import sys
import json
import ophion

o = ophion.Ophion(sys.argv[1])

print o.query().V().count().execute()
print o.query().E().count().execute()

print o.query().V().has("group", "Book").count().execute()

#print json.dumps(o.query().V().limit(10).execute(), indent=4)

print json.dumps(o.query().V().has("Id", "1").outgoing("similar").execute(), indent=4)
示例#4
0
BASE = os.path.dirname(__file__)
TESTS = os.path.join(BASE, "tests")

def clear_db(O):
    O.query().V().drop().execute()
    if int(O.query().V().count().first()['int_value']) != 0:
        print "Unable to clear database"
        sys.exit()
    if int(O.query().E().count().first()['int_value']) != 0:
        print "Unable to clear database"
        sys.exit()

if __name__ == "__main__":
    server = sys.argv[1]

    O = ophion.Ophion(server)
    if int(O.query().V().count().first()['int_value']) != 0:
        print "Need to start with empty DB"
        sys.exit()

    correct = 0
    total = 0
    for a in glob(os.path.join(TESTS, "ot_*.py")):
        name = os.path.basename(a)[:-3]
        mod = imp.load_source('test.%s' % name, a)
        for f in dir(mod):
            if f.startswith("test_"):
                func = getattr(mod,f)
                if callable(func):
                    try:
                        e = func(O)
示例#5
0
import ophion

G = ophion.Ophion('http://localhost:8000')

print G.query().addV("vertex1").property("field1", "value1").property(
    "field2", "value2").execute()
print G.query().addV("vertex2").execute()
print G.query().addV("vertex3").property("field1", "value3").property(
    "field2", "value4").execute()
print G.query().addV("vertex4").execute()

print G.query().V("vertex1").addE("friend").to("vertex2").execute()
print G.query().V("vertex2").addE("friend").to("vertex3").execute()
print G.query().V("vertex2").addE("parent").to("vertex4").execute()

for i in G.query().V().execute():
    print "found vertex", i

for i in G.query().E().execute():
    print "found edge", i

for i in G.query().V("vertex1").outgoing().execute():
    print "found vertex", i

for i in G.query().V("vertex1").outgoing().outgoing().has(
        "field1", "value4").incoming().execute():
    print "found vertex", i
示例#6
0
import ophion

G = ophion.Ophion('http://localhost:8201')

print G.query().addV("vertex1").property("field1", "value1").property(
    "field2", "value2").execute()
print G.query().addV("vertex2").execute()
print G.query().addV("vertex3").property("field1", "value3").property(
    "field2", "value4").execute()
print G.query().addV("vertex4").execute()

print G.query().V("vertex1").addE("friend").to("vertex2").execute()
print G.query().V("vertex2").addE("friend").to("vertex3").execute()
print G.query().V("vertex2").addE("parent").to("vertex4").execute()

for i in G.query().V().execute():
    print "found vertex", i

for i in G.query().E().execute():
    print "found edge", i

for i in G.query().V("vertex1").outgoing().execute():
    print "found vertex", i

for i in G.query().V("vertex1").outgoing().outgoing().has(
        "field1", "value4").incoming().execute():
    print "found vertex", i