Skip to content

Commit

Permalink
Merge pull request #123 from vreuter/attmap
Browse files Browse the repository at this point in the history
Attmap
  • Loading branch information
vreuter authored Feb 19, 2019
2 parents 904644b + 3f17b87 commit 3ccf473
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 85 deletions.
56 changes: 0 additions & 56 deletions pypiper/AttributeDict.py

This file was deleted.

1 change: 0 additions & 1 deletion pypiper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from ._version import __version__
from .manager import *
from .ngstk import *
from .AttributeDict import *
from .utils import *
from .pipeline import *
from .exceptions import *
Expand Down
4 changes: 2 additions & 2 deletions pypiper/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys
import time

from .AttributeDict import AttributeDict
from attmap import AttMapEcho
from .exceptions import PipelineHalt, SubprocessError
from .flags import *
from .utils import \
Expand Down Expand Up @@ -286,7 +286,7 @@ def __init__(
# later to pass to, for example, toolkits
import yaml
config = yaml.load(conf)
self.config = AttributeDict(config, default=True)
self.config = AttMapEcho(config)
else:
print("No config file")
self.config = None
Expand Down
20 changes: 10 additions & 10 deletions pypiper/ngstk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import re
import subprocess
import errno
from .AttributeDict import AttributeDict as _AttributeDict
from attmap import AttMapEcho
from .exceptions import UnsupportedFiletypeException
from .utils import is_fastq, is_gzipped_fastq, is_sam_or_bam



class NGSTk(_AttributeDict):
class NGSTk(AttMapEcho):
"""
Class to hold functions to build command strings used during pipeline runs.
Object can be instantiated with a string of a path to a yaml `pipeline config file`.
Since NGSTk inherits from `AttributeDict`, the passed config file and its elements
Since NGSTk inherits from `AttMapEcho`, the passed config file and its elements
will be accessible through the NGSTk object as attributes under `config` (e.g.
`NGSTk.tools.java`). In case no `config_file` argument is passed, all commands will
be returned assuming the tool is in the user's $PATH.
Expand Down Expand Up @@ -46,29 +46,29 @@ def __init__(self, config_file=None, pm=None):
# self.add_entries(**config)

if config_file is None:
super(NGSTk, self).__init__({}, default=True)
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, default=True)
super(NGSTk, self).__init__(config)

# Keep a link to the pipeline manager, if one is provided.
# if None is provided, instantiate "tools" and "parameters" with empty AttributeDicts
# if None is provided, instantiate "tools" and "parameters" with empty AttMaps
# this allows the usage of the same code for a command with and without using a pipeline manager
if pm is not None:
self.pm = pm
if hasattr(pm.config, "tools"):
self.tools = self.pm.config.tools
else:
self.tools = _AttributeDict(dict(), default=True)
self.tools = AttMapEcho()
if hasattr(pm.config, "parameters"):
self.parameters = self.pm.config.parameters
else:
self.parameters = _AttributeDict(dict(), default=True)
self.parameters = AttMapEcho()
else:
self.tools = _AttributeDict(dict(), default=True)
self.parameters = _AttributeDict(dict(), default=True)
self.tools = AttMapEcho()
self.parameters = AttMapEcho()

# If pigz is available, use that. Otherwise, default to gzip.
if hasattr(self.pm, "cores") and self.pm.cores > 1 and self.check_command("pigz"):
Expand Down
1 change: 1 addition & 0 deletions requirements/reqs-pypiper.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
attmap
pyyaml
psutil
16 changes: 0 additions & 16 deletions tests/test_attribute_dict.py

This file was deleted.

0 comments on commit 3ccf473

Please sign in to comment.