from Bio.KEGG.KGML import KGML_parser

import argparse
from import_utils import GraphImporter

parser = argparse.ArgumentParser(description='KEGG Importer')
parser.add_argument('--db', default='http://192.168.50.52:7475/db/data/')
parser.add_argument('--data_dir', '-d', default='./pws/',
                    help='data directory')
# parser.add_argument('--data_dir', '-d', default='/vagrant_data/kegg/',
#                    help='data directory')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery', type=int, default=100, help='commit every x steps')
args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)
if args.clear or True:
    importer.delete_all()

if not os.path.exists(args.data_dir):
    os.makedirs(args.data_dir)

files = [f for f in listdir(args.data_dir) if isfile(join(args.data_dir, f))]

if len(files) == 0:
    # download kgml files
    res = kegg_list('pathway', 'hsa').read()
    items = res.split('\n')
    for item in items[:len(items) - 1]:
        pathway_id = item[5:13]
        if pathway_id != 'hsa01100':
Exemplo n.º 2
0
import itertools

from import_utils import GraphImporter


parser = argparse.ArgumentParser(description='DBLP Importer')
parser.add_argument('--db', default="http://localhost:7474/db/data/")
parser.add_argument('--data_dir', '-d', default='/vagrant/_data', help='data directory')
parser.add_argument('--undirected', action='store_true', help='create undirected graph')
parser.add_argument('--sets', action='store_true', help='create set edges')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery', type=int, default=100, help='commit every x steps')
args = parser.parse_args()


importer = GraphImporter(args.db, args.commitEvery)
if args.clear:
  importer.delete_all()


def fix_string(v):
  v = v.replace(u'"',u"'")
  v = v.replace(u'\\',u'\\\\')
  return v

class DBLPImporter(xml.sax.ContentHandler):

  def __init__(self):
    self.c = 0
    self.last = None
    self.attr = None
Exemplo n.º 3
0
import json, os
import argparse
from import_utils import GraphImporter

parser = argparse.ArgumentParser(description='Marclab importer')
parser.add_argument('--db', default='http://localhost:7477/db/data/')
# parser.add_argument('--db', default='http://192.168.50.52:7477/db/data/')
parser.add_argument('--data_file', '-d', default='./data/marclab_476_4hops.json',
                    help='data directory')
# parser.add_argument('--data_dir', '-d', default='/vagrant_data/kegg/',
#                    help='data directory')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery', type=int, default=100, help='commit every x steps')
args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)
if args.clear or True:
  importer.delete_all()

with open(args.data_file) as f:
  doc = json.load(f)

  set_ids = dict()
  current_set_id = 0;

  nodes = doc["nodes"]

  for node in nodes:
    if node["Label"] is not None:

      if node["Label"] in set_ids:
Exemplo n.º 4
0
parser.add_argument('--db', default='http://localhost:7477/db/data/')
# parser.add_argument('--db', default='http://192.168.50.52:7477/db/data/')
parser.add_argument('--data_file',
                    '-d',
                    default='./data/marclab_476_4hops.json',
                    help='data directory')
# parser.add_argument('--data_dir', '-d', default='/vagrant_data/kegg/',
#                    help='data directory')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery',
                    type=int,
                    default=100,
                    help='commit every x steps')
args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)
if args.clear or True:
    importer.delete_all()

with open(args.data_file) as f:
    doc = json.load(f)

    set_ids = dict()
    current_set_id = 0

    nodes = doc["nodes"]

    for node in nodes:
        if node["Label"] is not None:

            if node["Label"] in set_ids:
parser = argparse.ArgumentParser(description='KEGG Importer')
parser.add_argument('--db', default='http://192.168.50.52:7475/db/data/')
parser.add_argument('--data_dir',
                    '-d',
                    default='./pws/',
                    help='data directory')
# parser.add_argument('--data_dir', '-d', default='/vagrant_data/kegg/',
#                    help='data directory')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery',
                    type=int,
                    default=100,
                    help='commit every x steps')
args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)
if args.clear or True:
    importer.delete_all()

if not os.path.exists(args.data_dir):
    os.makedirs(args.data_dir)

files = [f for f in listdir(args.data_dir) if isfile(join(args.data_dir, f))]

if len(files) == 0:
    # download kgml files
    res = kegg_list('pathway', 'hsa').read()
    items = res.split('\n')
    for item in items[:len(items) - 1]:
        pathway_id = item[5:13]
        if pathway_id != 'hsa01100':
Exemplo n.º 6
0
import pydotplus
import itertools

from import_utils import GraphImporter

parser = argparse.ArgumentParser(description='DOT Importer')
parser.add_argument('--db', default='http://localhost:7475/db/data/')
parser.add_argument('--data_dir', '-d', default='/vagrant_data/dot/', help='data directory')
parser.add_argument('--undirected', action='store_true', help='create undirected graph')
parser.add_argument('--sets', action='store_true', help='create set edges')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery', type=int, default=100, help='commit every x steps')

args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)


# importer.delete_all()


# extras for creating the fields
# MATCH (a:Disease)-[:`ConsistsOfEdge`]->(b) SET b.diseases = []
# MATCH (a:Disease)-[:`ConsistsOfEdge`]->(b) SET b.diseases = b.disease + a.id
# MATCH (a:Disease)-[:`ConsistsOfEdge`]->(b)-[l:LinkTo]->(c)<-[:ConsistsOfEdge]-(a) SET l.diseases = []
# MATCH (a:Disease)-[:`ConsistsOfEdge`]->(b)-[l:LinkTo]->(c)<-[:ConsistsOfEdge]-(a) SET l.diseases = l.diseases + a.id
# MATCH (a:Pathway)-[:`ConsistsOfEdge`]->(b) SET b.pathways = []
# MATCH (a:Pathway)-[:`ConsistsOfEdge`]->(b) SET b.pathways = b.pathways + a.id
# MATCH (a:Pathway)-[:`ConsistsOfEdge`]->(b)-[l:LinkTo]->(c)<-[:ConsistsOfEdge]-(a) SET l.pathways = []
# MATCH (a:Pathway)-[:`ConsistsOfEdge`]->(b)-[l:LinkTo]->(c)<-[:ConsistsOfEdge]-(a) SET l.pathways = l.pathways + a.id
# MATCH (a:Phenotype)-[:`ConsistsOfEdge`]->(b) SET b.phenotypes = []
Exemplo n.º 7
0
parser.add_argument('--data_dir',
                    '-d',
                    default='/vagrant/_data',
                    help='data directory')
parser.add_argument('--undirected',
                    action='store_true',
                    help='create undirected graph')
parser.add_argument('--sets', action='store_true', help='create set edges')
parser.add_argument('--clear', action='store_true', help='clear the graph')
parser.add_argument('--commitEvery',
                    type=int,
                    default=100,
                    help='commit every x steps')
args = parser.parse_args()

importer = GraphImporter(args.db, args.commitEvery)
if args.clear:
    importer.delete_all()


def fix_string(v):
    v = v.replace(u'"', u"'")
    v = v.replace(u'\\', u'\\\\')
    return v


class DBLPImporter(xml.sax.ContentHandler):
    def __init__(self):
        self.c = 0
        self.last = None
        self.attr = None