Skip to content
This repository has been archived by the owner on Mar 20, 2020. It is now read-only.

Commit

Permalink
#4 Fix directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshiyuki Yokoyama committed Jun 20, 2019
1 parent bbb66c7 commit 0a19fd9
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
# Tests
test/*.xg
test/*.pickle
test/xg
test/xg

__pycache__
File renamed without changes.
50 changes: 50 additions & 0 deletions src/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import List, NamedTuple
import pickle

class PathIndex(NamedTuple):
node: Node
index: int

class Graph:
version = 1.0
def __init__(self, nodes: list(Nodes), paths: list(Paths)):
self.nodes = nodes
self.paths = paths

def load_from_pickle(self, file: str):
self = pickle.load(file)

def load_form_xg(self, file: str, xg_bin: str):
raise NotImplementedError()

def dump():
raise NotImplementedError()

def save_as_pickle():
pickle.dump(self, file)

def save_as_xg():
raise NotImplementedError()

class Node:
def __init__(self, id: int, sequence: str, paths: list(PathIndex)):
self.id = id
self.sequence = sequence
self.paths = paths
#self.strand = strand

def alternative_nodes(self):
#WIP

class Path:
def __init__(self, name: str, nodes: list(Node)):
self.name = name
self.nodes = paths

if __name__ == "__main__":
location_of_xg = sys.argv[0]

### Usage
graph = Graph.load_form_xg
graph.save_as_pickle()

20 changes: 20 additions & 0 deletions src/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
from gfa import GFA

class GFATest(unittest.TestCase):
""" test class of gfa.py
"""

def test_gfa(self):
### Usage
self.maxDiff = None
location_of_xg = "test/xg"
graph = GFA.load_from_gfa("test/test.gfa")
graph.save_as_xg("test/test.xg", location_of_xg)
graph2 = GFA.load_form_xg("test/test.xg", location_of_xg)
self.assertEqual(len(graph.gfa.to_gfa1_s().split("\n")), len(graph2.gfa.to_gfa1_s().split("\n")))

if __name__ == "__main__":
unittest.main()


0 comments on commit 0a19fd9

Please sign in to comment.