Skip to content

Commit

Permalink
precommit formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ntalluri committed Sep 5, 2023
1 parent cae057a commit 319a5d3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
5 changes: 4 additions & 1 deletion src/allpairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import pandas as pd

from src.interactome import convert_directed_to_undirected, readd_direction_col_undirected
from src.interactome import (
convert_directed_to_undirected,
readd_direction_col_undirected,
)
from src.prm import PRM
from src.util import prepare_volume, run_container

Expand Down
29 changes: 15 additions & 14 deletions src/interactome.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pandas as pd


def convert_undirected_to_directed(df: pd.DataFrame) -> pd.DataFrame:
"""
turns a graph into a fully directed graph
Expand All @@ -25,10 +26,10 @@ def convert_undirected_to_directed(df: pd.DataFrame) -> pd.DataFrame:
new_df['Direction'] = 'D'
df.loc[mask, 'Direction'] = 'D'
df = pd.concat([df, new_df], ignore_index=True)

print("convert_undirected_to_directed")
print(df)

return df


Expand All @@ -41,12 +42,12 @@ def convert_directed_to_undirected(df: pd.DataFrame) -> pd.DateOffset:
@param df: input network df of edges, weights, and directionality
@return a dataframe with no directed edges in Direction column
"""

df["Direction"] = "U"

print("convert_directed_to_undirected")
print(df)

return df


Expand All @@ -61,10 +62,10 @@ def add_constant(df: pd.DataFrame, col_name: str, const: str) -> pd.DataFrame:
"""

df.insert(df.shape[1], col_name, const)

print("add_constant")
print(df)

return df


Expand All @@ -86,7 +87,7 @@ def add_directionality_constant(df: pd.DataFrame, col_name: str, dir_const: str

print("add_directionality_constant")
print(df)

return df

def readd_direction_col_mixed(df: pd.DataFrame, existing_direction_column: str, dir_const: str, undir_const: str) -> pd.DataFrame:
Expand All @@ -110,10 +111,10 @@ def readd_direction_col_mixed(df: pd.DataFrame, existing_direction_column: str,

mask_dir = df[existing_direction_column] == dir_const
df.loc[mask_dir, "Direction"] = "D"

print("readd_direction_col_mixed")
print(df)

return df

def readd_direction_col_undirected(df: pd.DataFrame) -> pd.DataFrame:
Expand All @@ -124,10 +125,10 @@ def readd_direction_col_undirected(df: pd.DataFrame) -> pd.DataFrame:
@return a df with Direction column added back
"""
df.insert(df.shape[1], "Direction", "U")

print("readd_direction_col_undirected")
print(df)

return df

def readd_direction_col_directed(df: pd.DataFrame) -> pd.DataFrame:
Expand All @@ -138,8 +139,8 @@ def readd_direction_col_directed(df: pd.DataFrame) -> pd.DataFrame:
@return a df with Direction column added back
"""
df.insert(df.shape[1], "Direction", "D")

print("readd_direction_col_directed")
print(df)

return df
5 changes: 4 additions & 1 deletion src/omicsintegrator2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import docker
import pandas as pd

from src.interactome import convert_directed_to_undirected, readd_direction_col_undirected
from src.interactome import (
convert_directed_to_undirected,
readd_direction_col_undirected,
)
from src.prm import PRM
from src.util import prepare_path_docker

Expand Down
15 changes: 8 additions & 7 deletions test/interactome/test_interactome.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from pathlib import Path

import pandas as pd

from src.interactome import (
convert_undirected_to_directed,
convert_directed_to_undirected,
add_constant,
add_directionality_constant,
convert_directed_to_undirected,
convert_undirected_to_directed,
readd_direction_col_directed,
readd_direction_col_mixed,
readd_direction_col_undirected,
readd_direction_col_directed,
)

IN_DIR = "test/interactome/input"
Expand Down Expand Up @@ -40,18 +41,18 @@ def add_const(self):
df = add_constant(df, "const", "-")
expected_df = pd.read_csv(EXPECTED_DIR+"add_const.csv", sep='\t')
assert df.equals(expected_df)

def add_directionality_const(self):
df = pd.read_csv(IN_DIR+ 'test-network.csv', sep='\t')
df = add_directionality_constant(df, "direct", "pd", "pp")
expected_df = pd.read_csv(EXPECTED_DIR+"add_directionality_const.csv", sep='\t')
assert df.equals(expected_df)

def readd_col_mixed(self):
None
assert True

def readd_col_undir(self):
None
assert True

def readd_col_dir(self):
None
assert True

0 comments on commit 319a5d3

Please sign in to comment.