Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MEO Node ID Error #190

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion spras/meo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

__all__ = ['MEO', 'write_properties']

# replaces all underscores in the node names with unicode seperator
ntalluri marked this conversation as resolved.
Show resolved Hide resolved
underscore_replacement = '꧁SEP꧂'

# Only supports the Random orientation algorithm
# Does not support MINSAT or MAXCSP
Expand Down Expand Up @@ -88,14 +90,18 @@ def generate_inputs(data, filename_map):
# TODO test whether this selection is needed, what values could the column contain that we would want to
# include or exclude?
nodes = nodes.loc[nodes[node_type]]
# replace _'s with underscore_replacement
nodes['NODEID'] = nodes['NODEID'].str.replace('_', underscore_replacement)
nodes.to_csv(filename_map[node_type], index=False, columns=['NODEID'], header=False)

# Create network file
edges = data.get_interactome()

# Format network file
edges = add_directionality_constant(edges, 'EdgeType', '(pd)', '(pp)')

# replace _'s with ꧁SEP꧂
edges['Interactor1'] = edges['Interactor1'].str.replace('_', underscore_replacement)
edges['Interactor2'] = edges['Interactor2'].str.replace('_', underscore_replacement)
edges.to_csv(filename_map['edges'], sep='\t', index=False,
columns=['Interactor1', 'EdgeType', 'Interactor2', 'Weight'], header=False)

Expand Down Expand Up @@ -181,6 +187,9 @@ def parse_output(raw_pathway_file, standardized_pathway_file):
# Columns Source Type Target Oriented Weight
df = raw_pathway_df(raw_pathway_file, sep='\t', header=0)
if not df.empty:
# Replace underscore_replacement with _
df['Source'] = df['Source'].str.replace(underscore_replacement, '_')
df['Target'] = df['Target'].str.replace(underscore_replacement, '_')
# Keep only edges that were assigned an orientation (direction)
df = df.loc[df['Oriented']]
# TODO what should be the edge rank?
Expand Down
4 changes: 2 additions & 2 deletions test/parse-outputs/expected/meo-pathway-expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Node1 Node2 Rank Direction
GENEA GENEC 1 D
GENEC GENEB 1 D
GENE_A GENE_C 1 D
GENE_C GENEB 1 D
4 changes: 2 additions & 2 deletions test/parse-outputs/input/meo-raw-pathway.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source Type Target Oriented Weight
GENEA pp GENEC true 0.5
GENEC pd GENEB true 0.5
GENE꧁SEP꧂A pp GENE꧁SEP꧂C true 0.5
GENE꧁SEP꧂C pd GENEB true 0.5
Loading