# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: plugins/dbupload/dbprofile.py
# class biosys_single(TableBase):
#     __tablename__ = 'biosys_562'
#     id = Column(Integer, primary_key=True, autoincrement=True)
#     tax_id = Column(String(10))
#     gene_id = Column(String(10))
#     bsid = Column(Integer)
#     Symbol = Column(String(64))
# 
# class Gene(TableBase):
#     __tablename__ = 'allgeneinfo_all'
#     tax_id = Column(String(10))
#     gene_id = Column(String(10), primary_key=True)
#     Symbol = Column(String(64))
#     LocusTag = Column(Text)
#     Synonyms = Column(Text)
#     dbXrefs = Column(Text)
#     chromosome = Column(Text)
#     map_location = Column(Text)
#     description = Column(Text)
#     type_of_gene = Column(Text)
#     Symbol_from_nomenclature_authority = Column(Text)
#     Full_name_from_nomenclature_authority = Column(Text)
#     Nomenclature_status = Column(Text)
#     Other_designations = Column(Text)
#     Modification_date = Column(Date)


from queue import Queue, PriorityQueue
from datetime import *
from database import session
from plugin import Plugin
from .dbupload.dbprofile import biosys_single, Gene
node_count = 0


class State:
    def __init__(self, f, g, cur, prepath):  # f is the distance to src, g is the distance to dst
        self.f = f
        self.g = g
        self.cur = cur
        self.prepath = prepath

    def __lt__(self, x):
        if self.f == x.f:
            return self.g < x.g
        else:
            return self.f < x.f


def calcu_dis(dst, n, maxlen):
    global dis
    visited = {}
    queue = Queue()

    dis[dst] = 0
    visited[dst] = True
    queue.put(dst)
    while not queue.empty():
        u = queue.get()
        # visited[u] = False
        Graph[u] = []
        for u_node in session.query(biosys_single).filter(biosys_single.gene_id == u):

# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: plugins/dbupload/dbprofile.py
# class biosys_single(TableBase):
#     __tablename__ = 'biosys_562'
#     id = Column(Integer, primary_key=True, autoincrement=True)
#     tax_id = Column(String(10))
#     gene_id = Column(String(10))
#     bsid = Column(Integer)
#     Symbol = Column(String(64))
# 
# class Gene(TableBase):
#     __tablename__ = 'allgeneinfo_all'
#     tax_id = Column(String(10))
#     gene_id = Column(String(10), primary_key=True)
#     Symbol = Column(String(64))
#     LocusTag = Column(Text)
#     Synonyms = Column(Text)
#     dbXrefs = Column(Text)
#     chromosome = Column(Text)
#     map_location = Column(Text)
#     description = Column(Text)
#     type_of_gene = Column(Text)
#     Symbol_from_nomenclature_authority = Column(Text)
#     Full_name_from_nomenclature_authority = Column(Text)
#     Nomenclature_status = Column(Text)
#     Other_designations = Column(Text)
#     Modification_date = Column(Date)


# Path: plugins/path_finder.py
from queue import Queue, PriorityQueue
from datetime import *
from database import session
from plugin import Plugin
from .dbupload.dbprofile import biosys_single, Gene

node_count = 0


class State:
    def __init__(self, f, g, cur, prepath):  # f is the distance to src, g is the distance to dst
        self.f = f
        self.g = g
        self.cur = cur
        self.prepath = prepath

    def __lt__(self, x):
        if self.f == x.f:
            return self.g < x.g
        else:
            return self.f < x.f


def calcu_dis(dst, n, maxlen):
    global dis
    visited = {}
    queue = Queue()

    dis[dst] = 0
    visited[dst] = True
    queue.put(dst)
    while not queue.empty():
        u = queue.get()
        # visited[u] = False
        Graph[u] = []
        for u_node in session.query(biosys_single).filter(biosys_single.gene_id == u):

            for node in session.query(biosys_single).filter(biosys_single.bsid == u_node.bsid):