This repository has been archived by the owner on Mar 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Toshiyuki Yokoyama
committed
Jun 20, 2019
1 parent
bbb66c7
commit 0a19fd9
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,6 @@ | |
# Tests | ||
test/*.xg | ||
test/*.pickle | ||
test/xg | ||
test/xg | ||
|
||
__pycache__ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|