def create_object(self, node_type): """ Returns an empty object of the node_type provided. It must be a valid object, or else an exception is raised. Args: node_type (str): The type of object desired. Returns: A object of the specified type. """ self.logger.debug("In create_object. Type: %s" % node_type) node = None if node_type == "project": from Project import Project self.logger.debug("Creating a Project.") node = Project() elif node_type == "visit": from Visit import Visit self.logger.debug("Creating a Visit.") node = Visit() elif node_type == "subject": from Subject import Subject self.logger.debug("Creating a Subject.") node = Subject() elif node_type == "sample": from Sample import Sample self.logger.debug("Creating a Sample.") node = Sample() elif node_type == "study": from Study import Study self.logger.debug("Creating a Study.") node = Study() elif node_type == "wgs_dna_prep": from WgsDnaPrep import WgsDnaPrep self.logger.debug("Creating a WgsDnaPrep.") node = WgsDnaPrep() elif node_type == "16s_dna_prep": from SixteenSDnaPrep import SixteenSDnaPrep self.logger.debug("Creating a SixteenSDnaPrep.") node = SixteenSDnaPrep() elif node_type == "16s_raw_seq_set": from SixteenSRawSeqSet import SixteenSRawSeqSet self.logger.debug("Creating a SixteenSRawSeqSet.") node = SixteenSRawSeqSet() elif node_type == "wgs_raw_seq_set": from WgsRawSeqSet import WgsRawSeqSet self.logger.debug("Creating a WgsRawSeqSet.") node = WgsRawSeqSet() elif node_type == "16s_trimmed_seq_set": from SixteenSTrimmedSeqSet import SixteenSTrimmedSeqSet self.logger.debug("Creating a SixteenSTrimmedSeqSet.") node = SixteenSTrimmedSeqSet() else: raise ValueError("Invalid node type specified: %" % node_type) return node
def sixteenSDnaPreps(self): """ Return an iterator of the 16S DNA preps prepared from this sample. """ self.logger.debug("In sixteenSDnaPreps().") for doc in self._dep_docs(): if doc['node_type'] == "16s_dna_prep": yield SixteenSDnaPrep.load_sixteenSDnaPrep(doc)
def create_16s_dna_prep(self): """ Returns an empty 16S DNA Prep object. Args: None Returns: A 16S DNA Prep object. """ self.logger.debug("In create_16s_dna_prep.") from SixteenSDnaPrep import SixteenSDnaPrep prep = SixteenSDnaPrep() return prep
def preps(self): """ Return an iterator of all the preps taken from this sample. """ self.logger.debug("In preps().") for doc in self._dep_docs(): if doc['node_type'] == "16s_dna_prep": yield SixteenSDnaPrep.load_sixteenSDnaPrep(doc) elif doc['node_type'] == "wgs_dna_prep": yield WgsDnaPrep.load_wgsDnaPrep(doc) elif doc['node_type'] == "host_seq_prep": yield HostSeqPrep.load_host_seq_prep(doc) elif doc['node_type'] == "microb_assay_prep": yield MicrobiomeAssayPrep.load_microassayprep(doc) elif doc['node_type'] == "host_assay_prep": yield HostAssayPrep.load_host_assay_prep(doc)