Skip to content

Commit

Permalink
crash fx
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry-Antipov committed Jun 4, 2024
1 parent e4d8fbe commit 1ee11a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/scripts/get_paths_fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import os
import graph_functions
from scaffolding import path_storage
import networkx as nx


def main():
rukki_path = sys.argv[1]
fasta_file = sys.argv[2]
graph = sys.argv[3]
out_fasta = sys.argv[4]
G = graph_functions.load_direct_graph(graph)
path_storage = path_storage.PathStorage(G)
path_storage.readFromFile(rukki_path)
path_storage.writeFasta(fasta_file, out_fasta)
rukki_path = sys.argv[1]
fasta_file = sys.argv[2]
graph_file = sys.argv[3]
out_fasta = sys.argv[4]
G = nx.DiGraph()
graph_functions.load_direct_graph(graph_file, G )
path_storage = path_storage.PathStorage(G)
path_storage.readFromFile(rukki_path)
path_storage.writePathAsFasta(fasta_file, out_fasta)
4 changes: 4 additions & 0 deletions src/scripts/graph_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,7 @@ def get_telomeric_nodes(telomere_locations_file, G):
aux_tel_nodes.add(telnode)
return aux_tel_nodes, new_G


def rc_seq(seq):
rc = {"A": "T", "T": "A", "G": "C", "C": "G", "N": "N"}
return "".join([rc[x] for x in seq[::-1]])
6 changes: 3 additions & 3 deletions src/scripts/scaffolding/path_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def writePathAsFasta(self, input_fasta, output_fasta):
cur = line.strip()[1:]
else:
seqs[cur] = line.strip()
with open(output_fasta, "a") as f:
with open(output_fasta, "w") as f:
for id in sorted(self.paths.keys()):
f.write(f">{id}\n")
prev_over = 0
Expand All @@ -124,10 +124,10 @@ def writePathAsFasta(self, input_fasta, output_fasta):
if node[-1] == "+":
f.write(seqs[nor_node][prev_over:])
else:
to_out = gf.rc_seq(seqs[nor_node][prev_over:])
to_out = graph_functions.rc_seq(seqs[nor_node][prev_over:])
f.write(to_out[prev_over:])
if node_id < len(self.paths[id]) - 1 and self.paths[id][node_id + 1][:-1] in seqs:
overlap = self.G.get_edge_data(nor_node, self.paths[id][node_id + 1][:-1])['overlap']
overlap = self.G.get_edge_data(node, self.paths[id][node_id + 1])['overlap']
else:
overlap = 0
f.write(f"\n")

0 comments on commit 1ee11a6

Please sign in to comment.