diff --git a/src/pynwb/file.py b/src/pynwb/file.py index 90ceaee24..31a6e75da 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -45,7 +45,8 @@ class Subject(NWBContainer): 'species', 'subject_id', 'weight', - 'date_of_birth' + 'date_of_birth', + 'strain' ) @docval({'name': 'age', 'type': str, 'doc': 'the age of the subject', 'default': None}, @@ -56,7 +57,8 @@ class Subject(NWBContainer): {'name': 'subject_id', 'type': str, 'doc': 'a unique identifier for the subject', 'default': None}, {'name': 'weight', 'type': str, 'doc': 'the weight of the subject', 'default': None}, {'name': 'date_of_birth', 'type': datetime, 'default': None, - 'doc': 'datetime of date of birth. May be supplied instead of age.'}) + 'doc': 'datetime of date of birth. May be supplied instead of age.'}, + {'name': 'strain', 'type': str, 'doc': 'the strain of the subject', 'default': None}) def __init__(self, **kwargs): kwargs['name'] = 'subject' call_docval_func(super(Subject, self).__init__, kwargs) @@ -67,6 +69,7 @@ def __init__(self, **kwargs): self.species = getargs('species', kwargs) self.subject_id = getargs('subject_id', kwargs) self.weight = getargs('weight', kwargs) + self.strain = getargs('strain', kwargs) date_of_birth = getargs('date_of_birth', kwargs) if date_of_birth and date_of_birth.tzinfo is None: self.date_of_birth = _add_missing_timezone(date_of_birth) diff --git a/tests/integration/hdf5/test_nwbfile.py b/tests/integration/hdf5/test_nwbfile.py index 87dfa2f93..61ed2407b 100644 --- a/tests/integration/hdf5/test_nwbfile.py +++ b/tests/integration/hdf5/test_nwbfile.py @@ -203,14 +203,15 @@ class TestSubjectIO(NWBH5IOMixin, TestCase): def setUpContainer(self): """ Return the test Subject """ - return Subject(age='12 mo', + return Subject(age='P90D', description='An unfortunate rat', genotype='WT', sex='M', species='Rattus norvegicus', subject_id='RAT123', weight='2 lbs', - date_of_birth=datetime(1970, 1, 1, 12, tzinfo=tzutc())) + date_of_birth=datetime(1970, 1, 1, 12, tzinfo=tzutc()), + strain='my_strain') def addContainer(self, nwbfile): """ Add the test Subject to the given NWBFile """ diff --git a/tests/unit/test_file.py b/tests/unit/test_file.py index 638e5e3b8..b7679e293 100644 --- a/tests/unit/test_file.py +++ b/tests/unit/test_file.py @@ -366,14 +366,15 @@ def test_multi_publications(self): class SubjectTest(TestCase): def setUp(self): - self.subject = Subject(age='12 mo', + self.subject = Subject(age='P90D', description='An unfortunate rat', genotype='WT', sex='M', species='Rattus norvegicus', subject_id='RAT123', weight='2 lbs', - date_of_birth=datetime(2017, 5, 1, 12, tzinfo=tzlocal())) + date_of_birth=datetime(2017, 5, 1, 12, tzinfo=tzlocal()), + strain='my_strain') self.start = datetime(2017, 5, 1, 12, tzinfo=tzlocal()) self.path = 'nwbfile_test.h5' self.nwbfile = NWBFile('a test session description for a test NWBFile', @@ -387,13 +388,15 @@ def setUp(self): subject=self.subject) def test_constructor(self): - self.assertEqual(self.subject.age, '12 mo') + self.assertEqual(self.subject.age, 'P90D') self.assertEqual(self.subject.description, 'An unfortunate rat') self.assertEqual(self.subject.genotype, 'WT') self.assertEqual(self.subject.sex, 'M') self.assertEqual(self.subject.species, 'Rattus norvegicus') self.assertEqual(self.subject.subject_id, 'RAT123') self.assertEqual(self.subject.weight, '2 lbs') + self.assertEqual(self.subject.date_of_birth, datetime(2017, 5, 1, 12, tzinfo=tzlocal())) + self.assertEqual(self.subject.strain, 'my_strain') def test_nwbfile_constructor(self): self.assertIs(self.nwbfile.subject, self.subject)