Skip to content

Commit

Permalink
Merge pull request #98 from monarch-initiative/develop
Browse files Browse the repository at this point in the history
Further minor QoL updates
  • Loading branch information
glass-ships authored Nov 11, 2022
2 parents 8742158 + 94a9a8d commit 86e0cd6
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
OS: ubuntu

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down
7 changes: 1 addition & 6 deletions examples/data/string.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ protein1 protein2 neighborhood fusion cooccurence coexpression experimental data
10090.ENSMUSP00000000001 10090.ENSMUSP00000020316 0 0 0 116 90 0 67 183
10090.ENSMUSP00000000001 10090.ENSMUSP00000022816 0 0 0 62 0 0 137 155
10090.ENSMUSP00000000001 10090.ENSMUSP00000048234 0 0 0 0 147 0 166 258
10090.ENSMUSP00000000001 10090.ENSMUSP00000017365 0 0 0 0 165 0 0 165
10090.ENSMUSP00000000001 10090.ENSMUSP00000033545 0 0 0 0 179 0 57 192
10090.ENSMUSP00000000001 10090.ENSMUSP00000113105 0 0 0 0 179 0 417 500
10090.ENSMUSP00000000001 10090.ENSMUSP00000036031 0 0 0 58 181 0 85 232
10090.ENSMUSP00000000001 10090.ENSMUSP00000039580 0 0 0 60 158 0 81 209
10090.ENSMUSP00000000001 10090.ENSMUSP00000040516 0 0 0 0 196 0 0 196
10090.ENSMUSP00000000001 10090.ENSMUSP00000012345 0 0 0 0 117 0 0 765
7 changes: 6 additions & 1 deletion examples/data/string2.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ protein1 protein2 neighborhood fusion cooccurence coexpression experimental data
10090.ENSMUSP00000000001 10090.ENSMUSP00000061493 0 0 0 156 45 0 0 159
10090.ENSMUSP00000000001 10090.ENSMUSP00000090329 0 0 0 0 196 0 0 196
10090.ENSMUSP00000000001 10090.ENSMUSP00000026270 0 0 0 187 0 0 49 193
10090.ENSMUSP00000000001 10090.ENSMUSP00000001115 0 0 0 0 119 0 148 218
10090.ENSMUSP00000000001 10090.ENSMUSP00000001115 0 0 0 0 119 0 148 918
10090.ENSMUSP00000000001 10090.ENSMUSP00000020101 0 0 0 0 181 0 85 218
10090.ENSMUSP00000000001 10090.ENSMUSP00000063804 0 0 0 0 179 0 57 192
10090.ENSMUSP00000000001 10090.ENSMUSP00000018012 0 0 0 65 220 0 100 286
10090.ENSMUSP00000000001 10090.ENSMUSP00000033545 0 0 0 0 179 0 57 192
10090.ENSMUSP00000000001 10090.ENSMUSP00000113105 0 0 0 0 179 0 417 500
10090.ENSMUSP00000000001 10090.ENSMUSP00000036031 0 0 0 58 181 0 85 232
10090.ENSMUSP00000000001 10090.ENSMUSP00000039580 0 0 0 60 158 0 81 209
10090.ENSMUSP00000000001 10090.ENSMUSP00000040516 0 0 0 0 196 0 0 196
27 changes: 14 additions & 13 deletions koza/cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,24 @@ def transform_source(

with open(source, 'r') as source_fh:
source_config = PrimaryFileConfig(**yaml.load(source_fh, Loader=UniqueIncludeLoader))
if not source_config.name:
source_config.name = Path(source).stem

if not source_config.name:
source_config.name = Path(source).stem

if not source_config.transform_code:
# look for it alongside the source conf as a .py file
source_config.transform_code = str(Path(source).parent / Path(source).stem) + '.py'
if not source_config.transform_code:
# look for it alongside the source conf as a .py file
source_config.transform_code = str(Path(source).parent / Path(source).stem) + '.py'

koza_source = Source(source_config, row_limit)
koza_source = Source(source_config, row_limit)

translation_table = get_translation_table(
global_table if global_table else source_config.global_table,
local_table if local_table else source_config.local_table,
)
translation_table = get_translation_table(
global_table if global_table else source_config.global_table,
local_table if local_table else source_config.local_table,
)

source_koza = set_koza_app(koza_source, translation_table, output_dir, output_format, schema)
source_koza.process_maps()
source_koza.process_sources()
source_koza = set_koza_app(koza_source, translation_table, output_dir, output_format, schema)
source_koza.process_maps()
source_koza.process_sources()


def validate_file(
Expand Down
7 changes: 4 additions & 3 deletions koza/io/reader/csv_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from koza.model.config.source_config import FieldType, HeaderMode
from koza.utils.log_utils import get_logger

LOG = get_logger(__name__)
# import logging
# LOG = logging.getLogger(__name__)
# LOG = get_logger(__name__)
import logging
LOG = logging.getLogger(__name__)


FIELDTYPE_CLASS = {
Expand Down Expand Up @@ -112,6 +112,7 @@ def __next__(self) -> Dict[str, Any]:

try:
if self.line_count == self.row_limit:
LOG.debug("Row limit reached")
raise StopIteration
else:
row = next(self.reader)
Expand Down
3 changes: 1 addition & 2 deletions koza/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def transform(
# os.path.splitext(os.path.basename(source))[0] # name of the yaml file without the yaml

set_log_config(logging.INFO if (verbose is None) else logging.DEBUG if (verbose == True) else logging.WARNING)
logfile = Path(f"logs/{source.split('/')[1]}_{source.split('/')[2][:-5]}.log")
logger = get_logger(__name__, verbose) if not logging.getLogger().hasHandlers() else logging.getLogger()
if log: fh = add_log_fh(logger, logfile)
if log: fh = add_log_fh(logger, f"logs/{Path(source).name}.log")

output_path = Path(output_dir)

Expand Down
2 changes: 1 addition & 1 deletion koza/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_logger(name: str, verbose: bool = None) -> logging.Logger:

logger = logging.getLogger(name)
logger.setLevel(log_level)
# logger.propagate = False
logger.propagate = False

if not logger.hasHandlers():
stream_handler = logging.StreamHandler(sys.stdout)
Expand Down
Loading

0 comments on commit 86e0cd6

Please sign in to comment.