Skip to content

Commit

Permalink
Version 1.0.1 with updates to VisitAtribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
victor73 committed Jan 26, 2018
1 parent 01d9cad commit 55a10d3
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
cutlass 1.0.1

* Support for mother_child, and time_during_pregnancy properties
in VisitAttribute.
* Minor pylint issues correct with VisitAttribute class.

- Victor <[email protected]> Fri, 26 Jan 2018 17:00:00 -0400

cutlass 1.0.0

* Added serology, host_epigenetics_raw_seq_set and host_variant_call nodes,
Expand Down
33 changes: 25 additions & 8 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
include cutlass/__init__.py
include cutlass/iHMPSession.py
include cutlass/AbundanceMatrix.py
include cutlass/Annotation.py
include cutlass/Base.py
include cutlass/ClusteredSeqSet.py
include cutlass/HostSeqSet.py
include cutlass/Cytokine.py
include cutlass/dependency.py
include cutlass/DiseaseMeta.py
include cutlass/HostAssayPrep.py
include cutlass/HostEpigeneticsRawSeqSet.py
include cutlass/HostSeqPrep.py
include cutlass/HostTranscriptomicsRawSeqSet.py
include cutlass/HostVariantCall.py
include cutlass/HostWgsRawSeqSet.py
include cutlass/iHMPSession.py
include cutlass/Lipidome.py
include cutlass/Metabolome.py
include cutlass/MicrobiomeAssayPrep.py
include cutlass/MicrobTranscriptomicsRawSeqSet.py
include cutlass/mimarks.py
include cutlass/mims.py
include cutlass/mixs.py
include cutlass/Project.py
include cutlass/Study.py
include cutlass/Subject.py
include cutlass/Proteome.py
include cutlass/ProteomeNonPride.py
include cutlass/Sample.py
include cutlass/SampleAttribute.py
include cutlass/Serology.py
include cutlass/SixteenSDnaPrep.py
include cutlass/SixteenSRawSeqSet.py
include cutlass/SixteenSTrimmedSeqSet.py
include cutlass/Study.py
include cutlass/Subject.py
include cutlass/SubjectAttribute.py
include cutlass/Util.py
include cutlass/ViralSeqSet.py
include cutlass/Visit.py
include cutlass/VisitAttribute.py
include cutlass/ViralSeqSet.py
include cutlass/WgsAssembledSeqSet.py
include cutlass/WgsDnaPrep.py
include cutlass/WgsRawSeqSet.py
include cutlass/mimarks.py
include cutlass/mims.py
include cutlass/mixs.py
include cutlass/aspera/__init__.py
include cutlass/aspera/aspera.py
recursive-include tests *.py
Expand Down
2 changes: 2 additions & 0 deletions cutlass/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import sys
import inspect

# pylint: disable=C0123,C0111

DATE_FORMAT = '%Y-%m-%d'
PYTHON_MIN_VERSION = (2, 7, 0)
PYTHON_MAX_VERSION = (3, 0, 0)
Expand Down
28 changes: 22 additions & 6 deletions cutlass/VisitAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from cutlass.Base import Base
from cutlass.Util import *

# pylint: disable=W0703, C1801, R0912
# pylint: disable=W0703, W0201, W0212, C1801, R0912

# Create a module logger named after the module
module_logger = logging.getLogger(__name__)
Expand All @@ -28,8 +28,10 @@ class VisitAttribute(Base):

__dict = {
'comment': [str, None],
'mother_child': [str, None],
'survey_id': [str, None],
'study': [str, None],
'time_during_pregnancy': [str, None],

# These are the disease metadata fields
'disease_comment': ["DiseaseMeta.comment", None],
Expand Down Expand Up @@ -192,10 +194,10 @@ class VisitAttribute(Base):
'dinner_food': [str, "dietary_log_today"],
'dinner_amt': [str, "dietary_log_today"],
'other_food_intake': [str, "dietary_log_today"]
# pylint: enable=C0326
}

@staticmethod
# pylint: disable=W0211,W0613
def _getx(self, propname, *args):
if propname in self.__dict:
propType = self.__dict[propname][0]
Expand All @@ -212,11 +214,13 @@ def _getx(self, propname, *args):
return value

@staticmethod
# pylint: disable=W0211
def _setx(self, value, n):
self._d[n] = value

@staticmethod
def _bindRead(name):
# pylint: disable=C0111
def getXXXX(self, *args):
return VisitAttribute._getx(self, name, *args)

Expand All @@ -225,6 +229,7 @@ def getXXXX(self, *args):

@staticmethod
def _bindWrite(name, t):
# pylint: disable=C0111
def setXXXX(self, val):
func = VisitAttribute._setx

Expand All @@ -246,7 +251,14 @@ def setXXXX(self, val):
setXXXX.__name__ = name
return setXXXX

def __init__(self):
def __init__(self, *args, **kwargs):
"""
Constructor for the VisitAttribute class. This initializes the fields
specific to the VisitAttribute class, and inherits from the Base class.
Args:
None
"""
self.logger = logging.getLogger(self.__module__ + '.' + self.__class__.__name__)

self.logger.addHandler(logging.NullHandler())
Expand All @@ -272,6 +284,8 @@ def __init__(self):
x = property(VisitAttribute._bindRead(propname), VisitAttribute._bindWrite(propname, t))
setattr(self.__class__, propname, x)

super(VisitAttribute, self).__init__(*args, **kwargs)

def __setattr__(self, name, value):
if name == "_d":
self.__dict__[name] = value
Expand Down Expand Up @@ -345,8 +359,8 @@ def load_visit_attr(attrib_data):

# Handle any special cases that we need too.
if (section == "excercise" or
(propname.startswith('breakfast') or propname.startswith('lunch') or
propname.startswith('dinner'))):
(propname.startswith('breakfast') or propname.startswith('lunch') or
propname.startswith('dinner'))):
(propbase, propkey) = propname.split('_', 1)

propval = attrib_metadata.get(section, {}).get(propbase, {}).get(propkey)
Expand All @@ -369,8 +383,10 @@ def load_visit_attr(attrib_data):

disease_props = dict(('disease_%s' % key, value) for key, value in
attrib_data['meta']['disease']['study_disease'].iteritems())

# This will have a double "disease" on it so we need to correct it.
disease_props['disease_ontology_id'] = disease_props.pop('disease_disease_ontology_id')
disease_props['disease_ontology_id'] = \
disease_props.pop('disease_disease_ontology_id')

map(lambda key: setattr(attrib, key, disease_props.get(key)), disease_props.keys())

Expand Down
8 changes: 5 additions & 3 deletions examples/visit_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ def set_logging():
va.comment = "test comment"
va.survey_id = "test survey id"
va.study = "prediabetes"
va.mother_child = "mother"
va.time_during_pregnancy = "first_trimester"
va.add_tag("test")
va.add_tag("visit_attr")
va.links = {"associated_with": ["610a4911a5ca67de12cdc1e4b400f121"]}
va.links = {"associated_with": ["610a4911a5ca67de12cdc1e4b400f121"]}

va.disease_study_status = "test disease status"
va.disease_name = "test disease name"
va.disease_study_status = "affected"
va.disease_name = "obesity"
va.disease_description = "test disease description"
va.disease_nci_id = "NCI id"
va.disease_mesh_id = "MESH id"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Utility function to read files. Used for the long_description.
def read(fname):
"""Reads the description of the package from the README.md file. """
""" Reads the description of the package from the README.md file. """
return open(os.path.join(os.path.dirname(__file__), fname)).read()

def get_version():
Expand Down
18 changes: 18 additions & 0 deletions tests/test_visit_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ def testComment(self):

self.util.stringTypeTest(self, attr, "comment")

self.util.stringPropertyTest(self, attr, "comment")

def testMotherChild(self):
""" Test the mother_child property. """
attr = self.session.create_visit_attr()

self.util.stringTypeTest(self, attr, "mother_child")

self.util.stringPropertyTest(self, attr, "mother_child")

def testTimeDuringPregnancy(self):
""" Test the time_during_pregnancy property. """
attr = self.session.create_visit_attr()

self.util.stringTypeTest(self, attr, "time_during_pregnancy")

self.util.stringPropertyTest(self, attr, "time_during_pregnancy")

def testClinicalPatientAge(self):
""" Test the age property. """
attr = self.session.create_visit_attr()
Expand Down

0 comments on commit 55a10d3

Please sign in to comment.