From b894a8efe9f0620597ac8b9e63ecf1af86ade62a Mon Sep 17 00:00:00 2001 From: Vince Date: Wed, 19 Jun 2019 22:16:42 -0400 Subject: [PATCH] use yacman; close #156 --- pypiper/manager.py | 8 ++------ pypiper/ngstk.py | 14 ++++---------- requirements/reqs-ngstk.txt | 2 +- requirements/reqs-pypiper.txt | 4 ++-- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pypiper/manager.py b/pypiper/manager.py index c60b1feb..25be0109 100644 --- a/pypiper/manager.py +++ b/pypiper/manager.py @@ -29,6 +29,7 @@ from attmap import AttMapEcho from hashlib import md5 +from yacman import load_yaml from .exceptions import PipelineHalt, SubprocessError from .flags import * from .utils import \ @@ -315,12 +316,7 @@ def __init__( if config_to_load is not None: print("\nLoading config file: {}\n".format(config_to_load)) with open(config_to_load, 'r') as conf: - # Set the args to the new config file, so it can be used - # later to pass to, for example, toolkits - import yaml - # An also use yaml.FullLoader for trusted input. . . - config = yaml.load(conf, Loader=yaml.SafeLoader) - self.config = AttMapEcho(config) + self.config = AttMapEcho(load_yaml(conf)) else: print("No config file") self.config = None diff --git a/pypiper/ngstk.py b/pypiper/ngstk.py index be1ee191..d3bd3355 100755 --- a/pypiper/ngstk.py +++ b/pypiper/ngstk.py @@ -1,15 +1,15 @@ -#!/usr/env python +""" Broadly applicable NGS processing/analysis functionality """ import os import re import subprocess import errno from attmap import AttMapEcho +from yacman import load_yaml from .exceptions import UnsupportedFiletypeException from .utils import is_fastq, is_gzipped_fastq, is_sam_or_bam - class NGSTk(AttMapEcho): """ Class to hold functions to build command strings used during pipeline runs. @@ -42,14 +42,8 @@ class NGSTk(AttMapEcho): def __init__(self, config_file=None, pm=None): # parse yaml into the project's attributes # self.add_entries(**config) - - if config_file is None: - super(NGSTk, self).__init__() - else: - import yaml - with open(config_file, 'r') as config_file: - config = yaml.load(config_file) - super(NGSTk, self).__init__(config) + super(NGSTk, self).__init__( + None if config_file is None else load_yaml(config_file)) # Keep a link to the pipeline manager, if one is provided. # if None is provided, instantiate "tools" and "parameters" with empty AttMaps diff --git a/requirements/reqs-ngstk.txt b/requirements/reqs-ngstk.txt index 85b710ed..80184784 100644 --- a/requirements/reqs-ngstk.txt +++ b/requirements/reqs-ngstk.txt @@ -1,4 +1,4 @@ numpy pandas pysam -pyyaml +yacman diff --git a/requirements/reqs-pypiper.txt b/requirements/reqs-pypiper.txt index 78ea834a..9ed3e149 100644 --- a/requirements/reqs-pypiper.txt +++ b/requirements/reqs-pypiper.txt @@ -1,4 +1,4 @@ attmap>=0.12.5 -pyyaml>=5 psutil -pandas \ No newline at end of file +pandas +yacman