Пример #1
0
    def testWgsRawSeqSet(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        seq_set = session.create_wgs_raw_seq_set()
        self.failIf(seq_set is None)

        from cutlass import WgsRawSeqSet
        self.failUnless(isinstance(seq_set, WgsRawSeqSet))
Пример #2
0
    def _configure(self):
        session = cutlass.iHMPSession(self.options['serialize']['dcc_user'],
                                      self.options['serialize']['dcc_pw'])
        study = cutlass.Study.load(self.options['serialize']['study_id'])

        records_wgs = list()
        records_16s = list()
        for subject in study.subjects():
            for visit in subject.visits():
                for sample in visit.samples():
                    prepseqs_16s = get_prepseqs(sample.sixteenSDnaPreps())
                    records_16s.append(SubmitRecord(sample, prepseqs_16s))
                    prepseqs_wgs = get_prepseqs(sample.wgsDnaPreps())
                    records_wgs.append(SubmitRecord(sample, prepseqs_wgs))

        unsequenced, recs_16s, recs_wgs = filter_unsequenced(
            records_wgs, records_16s)
        submission_file = os.path.join(self.products_dir, "submission.xml")
        ready_file = os.path.join(self.products_dir, "submit.ready")
        yield workflows.serialize(session, study, records_16s,
                                  self.cached_16s_files, records_wgs,
                                  self.cached_wgs_files, unsequenced,
                                  submission_file, ready_file,
                                  self.products_dir,
                                  **self.options['serialize'])

        yield workflows.upload(self.cached_16s_files,
                               self.cached_wgs_files,
                               submission_file,
                               ready_file,
                               products_dir=self.products_dir,
                               **self.options['upload'])

        yield workflows.report(session, ready_file + ".complete",
                               **self.options['upload'])
Пример #3
0
    def testWgsDnaPrep(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        prep = session.create_wgs_dna_prep()
        self.failIf(prep is None)

        from cutlass import WgsDnaPrep
        self.failUnless(isinstance(prep, WgsDnaPrep))
Пример #4
0
    def testCreateMicrobiomeAssayPrep(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        microbiome_assay_prep = session.create_microbiome_assay_prep()
        self.failIf(microbiome_assay_prep is None)

        from cutlass import MicrobiomeAssayPrep
        self.failUnless(isinstance(microbiome_assay_prep, MicrobiomeAssayPrep))
Пример #5
0
    def testCreateHostTranscriptomicsRawSeqSet(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        htrss = session.create_host_transcriptomics_raw_seq_set()
        self.failIf(htrss is None)

        from cutlass import HostTranscriptomicsRawSeqSet
        self.failUnless(isinstance(htrss, HostTranscriptomicsRawSeqSet))
Пример #6
0
    def testCreateMetabolome(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        metabolome = session.create_metabolome()
        self.failIf(metabolome is None)

        from cutlass import Metabolome
        self.failUnless(isinstance(metabolome, Metabolome))
Пример #7
0
    def testCreateCytokine(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        cytokine = session.create_cytokine()
        self.failIf(cytokine is None)

        from cutlass import Cytokine
        self.failUnless(isinstance(cytokine, Cytokine))
Пример #8
0
    def testCreateHostSeqPrep(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        prep = session.create_host_seq_prep()
        self.failIf(prep is None)

        from cutlass import HostSeqPrep
        self.failUnless(isinstance(prep, HostSeqPrep))
Пример #9
0
    def testCreateAnnotation(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        annot = session.create_annotation()
        self.failIf(annot is None)

        from cutlass import Annotation
        self.failUnless(isinstance(annot, Annotation))
Пример #10
0
    def testCreateClusteredSeqSet(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        css = session.create_clustered_seq_set()
        self.failIf(css is None)

        from cutlass import ClusteredSeqSet
        self.failUnless(isinstance(css, ClusteredSeqSet))
Пример #11
0
    def testCreateAbundanceMatrix(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        matrix = session.create_abundance_matrix()
        self.failIf(matrix is None)

        from cutlass import AbundanceMatrix
        self.failUnless(isinstance(matrix, AbundanceMatrix))
Пример #12
0
    def testCreate16STrimmedSeqSet(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        seq_set = session.create_16s_trimmed_seq_set()
        self.failIf(seq_set is None)

        from cutlass import SixteenSTrimmedSeqSet
        self.failUnless(isinstance(seq_set, SixteenSTrimmedSeqSet))
Пример #13
0
    def testCreate16SDnaPrep(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        prep = session.create_16s_dna_prep()
        self.failIf(prep is None)

        from cutlass import SixteenSDnaPrep
        self.failUnless(isinstance(prep, SixteenSDnaPrep))
Пример #14
0
    def get_session():
        config_paths = [
            ".cutlass_test.ini",
            os.path.expanduser('~/.cutlass_test.ini')
        ]

        parser = ConfigParser.ConfigParser()
        successfullyReadFiles = parser.read(config_paths)

        if len(successfullyReadFiles) == 0:
            raise Exception(
                "Unable to find .cutlass_test.ini in cwd or in home directory")

        section = 'cutlass'
        host = parser.get(section, 'host')
        port = parser.get(section, 'port')
        username = parser.get(section, 'username')
        password = parser.get(section, 'password')
        ssl = parser.getboolean(section, 'ssl')

        #print("{} - {} - {} - {} - {}".format(host, port, username, password, ssl))

        if (host is None or port is None or username is None
                or password is None):
            raise Exception(
                "Missing configuration parameters in .cutlass_test.ini.")

        session = iHMPSession(username,
                              password,
                              server=host,
                              port=port,
                              ssl=ssl)

        return session
Пример #15
0
    def testCreateMicrobTranscriptomicsRawSeqSet(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        raw_seq_set = session.create_microb_transcriptomics_raw_seq_set()
        self.failIf(raw_seq_set is None)

        from cutlass import MicrobTranscriptomicsRawSeqSet
        self.failUnless(isinstance(raw_seq_set, MicrobTranscriptomicsRawSeqSet))
Пример #16
0
    def testCreateVisitAttribute(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        visit_attr = session.create_visit_attr()
        self.failIf(visit_attr is None)

        from cutlass import VisitAttribute
        self.failUnless(isinstance(visit_attr, VisitAttribute))
Пример #17
0
    def testCreateProject(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        project = session.create_project()
        self.failIf(project is None)

        from cutlass import Project
        self.failUnless(isinstance(project, Project))
Пример #18
0
    def testCreateStudy(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        study = session.create_study()
        self.failIf(study is None)

        from cutlass import Study
        self.failUnless(isinstance(study, Study))
Пример #19
0
    def testCreateVisit(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        visit = session.create_visit()
        self.failIf(visit is None)

        from cutlass import Visit
        self.failUnless(isinstance(visit, Visit))
Пример #20
0
    def testCreateSubjectAttribute(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        subject_attr = session.create_subject_attr()
        self.failIf(subject_attr is None)

        from cutlass import SubjectAttribute
        self.failUnless(isinstance(subject_attr, SubjectAttribute))
Пример #21
0
    def testCreateSubject(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        subject = session.create_subject()
        self.failIf(subject is None)

        from cutlass import Subject
        self.failUnless(isinstance(subject, Subject))
Пример #22
0
    def testCreateSample(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        sample = session.create_sample()
        self.failIf(sample is None)

        from cutlass import Sample
        self.failUnless(isinstance(sample, Sample))
Пример #23
0
    def testCreateProteome(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
        proteome = session.create_proteome()
        self.failIf(proteome is None)

        from cutlass import Proteome
        self.failUnless(isinstance(proteome, Proteome))
Пример #24
0
def main(args):
    session = cutlass.iHMPSession('cesar.arze',
                                  'fishnet-socket-dolphin-can',
                                  ssl=False)
    osdf = session.get_osdf()

    raw_abund_matrices = osdf.oql_query(
        'ihmp',
        '"abundance_matrix"[node_type] && "host_transcriptome"[meta.matrix_type]'
    )

    abundance_matrices = map(
        cutlass.AbundanceMatrix.load,
        [m.get('id') for m in raw_abund_matrices.get('results')])
    host_raw_seq_sets = map(
        cutlass.HostTranscriptomicsRawSeqSet.load,
        [m.links.get('computed_from')[0] for m in abundance_matrices])
    host_seq_preps = map(cutlass.HostSeqPrep.load, [
        seq_set.links.get('sequenced_from')[0] for seq_set in host_raw_seq_sets
    ])
    samples = map(
        cutlass.Sample.load,
        [prep.links.get('prepared_from')[0] for prep in host_seq_preps])
    sample_attrs = map(cutlass.Sample.sampleAttributes, samples)
    visits = map(
        cutlass.Visit.load,
        [sample.links.get('collected_during')[0] for sample in samples])
    visit_attrs = map(cutlass.Visit.visit_attributes, visits)

    host_tx_tree = zip(visits, visit_attrs, samples, sample_attrs,
                       host_seq_preps, host_raw_seq_sets, abundance_matrices)

    for (visit, visit_attr_g, sample, sample_attr_g, seq_prep, seq_set,
         abundance_matrix) in host_tx_tree:
        print "DELETING the following objects:"
        print "\t - %s" % visit.visit_id
        print "\t - %s" % sample.name
        print "\t - %s" % seq_prep.prep_id
        print "\t - %s" % seq_set.comment
        print "\t - %s" % abundance_matrix._urls
        print

        if not args.dry_run:
            sample_attr = next(sample_attr_g, None)
            visit_attr = next(visit_attr_g, None)

            abundance_matrix.delete()
            seq_set.delete()
            seq_prep.delete()
            if sample_attr:
                sample_attr.delete()
            else:
                print "DEBUG: No sample_attr"
            sample.delete()
            if visit_attr:
                visit_attr.delete()
            else:
                print "DEBUG: No visit_attr"
            visit.delete()
Пример #25
0
    def testUsername(self):
        """ Test the username property. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)

        self.util.stringTypeTest(self, session, "username")

        self.util.stringPropertyTest(self, session, "username")
Пример #26
0
    def testPassword(self):
        """ Test the password property. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)

        self.util.stringTypeTest(self, session, "password")

        self.util.stringPropertyTest(self, session, "password")
Пример #27
0
    def testPort(self):
        """ Test the port property. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)

        self.util.intTypeTest(self, session, "port")

        self.util.intPropertyTest(self, session, "port")
Пример #28
0
    def testSSL(self):
        """ Test the ssl property. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)

        self.util.boolTypeTest(self, session, "ssl")

        self.util.boolPropertyTest(self, session, "ssl")
Пример #29
0
    def testCreate16SDnaPrep(self):
        """ Test the create_16s_dna_prep() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        prep = session.create_16s_dna_prep()
        self.failIf(prep is None)

        from cutlass import SixteenSDnaPrep
        self.failUnless(isinstance(prep, SixteenSDnaPrep))
Пример #30
0
    def testCreate16STrimmedSeqSet(self):
        """ Test the create_16s_trimmed_seq_set() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        seq_set = session.create_16s_trimmed_seq_set()
        self.failIf(seq_set is None)

        from cutlass import SixteenSTrimmedSeqSet
        self.failUnless(isinstance(seq_set, SixteenSTrimmedSeqSet))
Пример #31
0
    def testWgsRawSeqSet(self):
        """ Test the create_wgs_raw_seq_set() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        seq_set = session.create_wgs_raw_seq_set()
        self.failIf(seq_set is None)

        from cutlass import WgsRawSeqSet
        self.failUnless(isinstance(seq_set, WgsRawSeqSet))
Пример #32
0
    def testCreateVisitAttribute(self):
        """ Test the create_visit_attribute() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        visit_attr = session.create_visit_attr()
        self.failIf(visit_attr is None)

        from cutlass import VisitAttribute
        self.failUnless(isinstance(visit_attr, VisitAttribute))
Пример #33
0
    def testCreateSerology(self):
        """ Test the create_serology() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        sero = session.create_serology()
        self.failIf(sero is None)

        from cutlass import Serology
        self.failUnless(isinstance(sero, Serology))
Пример #34
0
    def testCreateSubject(self):
        """ Test the create_subject() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        subject = session.create_subject()
        self.failIf(subject is None)

        from cutlass import Subject
        self.failUnless(isinstance(subject, Subject))
Пример #35
0
    def testCreateVisit(self):
        """ Test the create_visit() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        visit = session.create_visit()
        self.failIf(visit is None)

        from cutlass import Visit
        self.failUnless(isinstance(visit, Visit))
Пример #36
0
    def testCreateSample(self):
        """ Test the create_sample() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        sample = session.create_sample()
        self.failIf(sample is None)

        from cutlass import Sample
        self.failUnless(isinstance(sample, Sample))
Пример #37
0
    def testCreateAbundanceMatrix(self):
        """ Test the create_abundance_matrix() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        matrix = session.create_abundance_matrix()
        self.failIf(matrix is None)

        from cutlass import AbundanceMatrix
        self.failUnless(isinstance(matrix, AbundanceMatrix))
Пример #38
0
    def testCreateProteome(self):
        """ Test the create_proteome() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        proteome = session.create_proteome()
        self.failIf(proteome is None)

        from cutlass import Proteome
        self.failUnless(isinstance(proteome, Proteome))
Пример #39
0
    def testCreateMetabolome(self):
        """ Test the create_metabolome() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        metabolome = session.create_metabolome()
        self.failIf(metabolome is None)

        from cutlass import Metabolome
        self.failUnless(isinstance(metabolome, Metabolome))
Пример #40
0
    def testCreateHostSeqPrep(self):
        """ Test the create_host_seq_prep() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        prep = session.create_host_seq_prep()
        self.failIf(prep is None)

        from cutlass import HostSeqPrep
        self.failUnless(isinstance(prep, HostSeqPrep))
Пример #41
0
    def testCreateHostTranscriptomicsRawSeqSet(self):
        """ Test the create_host_transcriptomics_raw_seq_set() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        htrss = session.create_host_transcriptomics_raw_seq_set()
        self.failIf(htrss is None)

        from cutlass import HostTranscriptomicsRawSeqSet
        self.failUnless(isinstance(htrss, HostTranscriptomicsRawSeqSet))
Пример #42
0
    def testCreateCytokine(self):
        """ Test the create_cytokine() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        cytokine = session.create_cytokine()
        self.failIf(cytokine is None)

        from cutlass import Cytokine
        self.failUnless(isinstance(cytokine, Cytokine))
Пример #43
0
    def testCreateClusteredSeqSet(self):
        """ Test the create_clustered_seq_set() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        css = session.create_clustered_seq_set()
        self.failIf(css is None)

        from cutlass import ClusteredSeqSet
        self.failUnless(isinstance(css, ClusteredSeqSet))
Пример #44
0
    def testCreateAnnotation(self):
        """ Test the create_annotation() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        annot = session.create_annotation()
        self.failIf(annot is None)

        from cutlass import Annotation
        self.failUnless(isinstance(annot, Annotation))
Пример #45
0
    def testCreateStudy(self):
        """ Test the create_study() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        study = session.create_study()
        self.failIf(study is None)

        from cutlass import Study
        self.failUnless(isinstance(study, Study))
Пример #46
0
    def testCreateMicrobiomeAssayPrep(self):
        """ Test the create_microbiome_assay_prep() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        microbiome_assay_prep = session.create_microbiome_assay_prep()
        self.failIf(microbiome_assay_prep is None)

        from cutlass import MicrobiomeAssayPrep
        self.failUnless(isinstance(microbiome_assay_prep, MicrobiomeAssayPrep))
Пример #47
0
    def testCreateMicrobTranscriptomicsRawSeqSet(self):
        """ Test the create_microb_transcriptomics_raw_seq_set() method. """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)
        raw_seq_set = session.create_microb_transcriptomics_raw_seq_set()
        self.failIf(raw_seq_set is None)

        from cutlass import MicrobTranscriptomicsRawSeqSet
        self.failUnless(isinstance(raw_seq_set,
                                   MicrobTranscriptomicsRawSeqSet))
def main(args):
    session = cutlass.iHMPSession(args.username, args.password, ssl=False)
    osdf = session.get_osdf()

    root_node = build_osdf_tree(args.study_id)

    if args.node_type_filter:
        root_node = filter_osdf_tree(root_node, args.node_type_filter)
            
    delete_nodes(root_node, args.dry_run, args.delete_root)
Пример #49
0
    def testCreateSession(self):
        success = False
        session = None
        try:
            session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)
            success = True
        except:
            pass

        self.failUnless(success)
        self.failIf(session is None)
Пример #50
0
    def testCreateSession(self):
        """ Test the constructor for creating sessions. """
        success = False
        session = None
        try:
            session = iHMPSession(IHMPSessionTest.username,
                                  IHMPSessionTest.password)
            success = True
        except Exception:
            pass

        self.failUnless(success)
        self.failIf(session is None)
Пример #51
0
    def _configure(self):
        session = cutlass.iHMPSession(self.options['serialize']['dcc_user'],
                                      self.options['serialize']['dcc_pw'])
        study = cutlass.Study.load(self.options['serialize']['study_id'])

        records_wgs = list()
        records_16s = list()
        for subject in study.subjects():
            for visit in subject.visits():
                for sample in visit.samples():
                    prepseqs_16s = get_prepseqs(sample.sixteenSDnaPreps())
                    records_16s.append(SubmitRecord(sample, prepseqs_16s))
                    prepseqs_wgs = get_prepseqs(sample.wgsDnaPreps())
                    records_wgs.append(SubmitRecord(sample, prepseqs_wgs))

        unsequenced, recs_16s, recs_wgs = filter_unsequenced(
            records_wgs, records_16s)

        submission_file = os.path.join(self.products_dir, "submission.xml")
        ready_file = os.path.join(self.products_dir, "submit.ready")
        six_fnames, wgs_fnames, tasks = workflows.download_upload(
            recs_16s,
            self.cached_16s_files,
            recs_wgs,
            self.cached_wgs_files,
            dcc_user=self.options['serialize']['dcc_user'],
            dcc_pw=self.options['serialize']['dcc_pw'],
            ncbi_srv=self.options['upload']['remote_srv'],
            ncbi_path=self.options['upload']['remote_path'],
            ncbi_user=self.options['upload']['user'],
            ncbi_keyfile=self.options['upload']['keyfile'],
            products_dir=self.products_dir)
        for t in tasks:
            yield t

        yield workflows.serialize(session, study, recs_16s, six_fnames,
                                  recs_wgs, wgs_fnames, unsequenced,
                                  submission_file, ready_file,
                                  self.products_dir,
                                  **self.options['serialize'])

        yield workflows.kickoff(submission_file,
                                ready_file,
                                six_fnames + wgs_fnames,
                                products_dir=self.products_dir,
                                **self.options['upload'])

        yield workflows.report(session, ready_file + ".complete",
                               **self.options['upload'])
Пример #52
0
    def testCreateObjectMethods(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)

        node_types = [
                      "16s_dna_prep", "16s_raw_seq_set", "16s_trimmed_seq_set",
                      "annotation", "abundance_matrix", "clustered_seq_set",
                      "cytokine", "host_assay_prep", "host_seq_prep",
                      "host_transcriptomics_raw_seq_set", "host_wgs_raw_seq_set",
                      "lipidome", "metabolome", "microbiome_assay_prep",
                      "microb_transcriptomics_raw_seq_set",
                      "project", "proteome", "sample", "sample_attr", "study",
                      "subject", "subject_attr", "viral_seq_set",
                      "visit", "visit_attr", "wgs_assembled_seq_set",
                      "wgs_raw_seq_set", "wgs_dna_prep" ]

        for node_type in node_types:
             instance = session.create_object(node_type)
             self.failIf(instance is None)
Пример #53
0
    def testUsername(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)

        # Test the username getter.
        self.assertEquals(session.username, IHMPSessionTest.username)

        with self.assertRaises(ValueError):
            session.username = 13

        with self.assertRaises(ValueError):
            session.username = True

        with self.assertRaises(ValueError):
            session.username = {}

        with self.assertRaises(ValueError):
            session.username = []

        # Test the username setter.
        newUsername = "******"
        session.username = newUsername
        self.assertEquals(session.username, newUsername)
Пример #54
0
    def testPassword(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)

        # Test the default password getter
        self.assertEquals(session.password, IHMPSessionTest.password)

        with self.assertRaises(ValueError):
            session.password = 13

        with self.assertRaises(ValueError):
            session.password = True

        with self.assertRaises(ValueError):
            session.password = {}

        with self.assertRaises(ValueError):
            session.password = []

        # Test the password setter.
        newPassword = "******"
        session.password = newPassword
        self.assertEquals(session.password, newPassword)
Пример #55
0
    def testPort(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)

        # Test the default port
        self.assertEquals(session.port, 8123)

        with self.assertRaises(ValueError):
            session.port = "test"

        with self.assertRaises(ValueError):
            session.port = True

        with self.assertRaises(ValueError):
            session.port = {}

        with self.assertRaises(ValueError):
            session.port = []

        # Test the port setter.
        newPort = 8000
        session.port = newPort
        self.assertEquals(session.port, newPort)
Пример #56
0
    def testSSL(self):
        session = iHMPSession(IHMPSessionTest.username, IHMPSessionTest.password)

        # Test the default SSL flag (should be true).
        self.assertTrue(session.ssl)

        with self.assertRaises(ValueError):
            session.ssl = "test"

        with self.assertRaises(ValueError):
            session.ssl = 13

        with self.assertRaises(ValueError):
            session.ssl = {}

        with self.assertRaises(ValueError):
            session.ssl = []

        # Test the SSL setter.
        newSSL = False
        session.ssl = newSSL
        self.assertFalse(session.ssl, newSSL)
Пример #57
0
    def testCreateObjectMethods(self):
        """
        Test the create_XXX() methods, where XXX is the name
        of a particular node type.
        """
        session = iHMPSession(IHMPSessionTest.username,
                              IHMPSessionTest.password)

        node_types = [
            "16s_dna_prep", "16s_raw_seq_set", "16s_trimmed_seq_set",
            "annotation", "abundance_matrix", "clustered_seq_set", "cytokine",
            "host_assay_prep", "host_epigenetics_raw_seq_set", "host_seq_prep",
            "host_transcriptomics_raw_seq_set", "host_wgs_raw_seq_set",
            "lipidome", "metabolome", "microbiome_assay_prep",
            "microb_transcriptomics_raw_seq_set", "project", "proteome",
            "sample", "sample_attr", "serology", "study", "subject",
            "subject_attr", "viral_seq_set", "visit", "visit_attr",
            "wgs_assembled_seq_set", "wgs_raw_seq_set", "wgs_dna_prep"
        ]

        for node_type in node_types:
            instance = session.create_object(node_type)
            self.failIf(instance is None)
Пример #58
0
    def get_session():
        config_paths = [".cutlass_test.ini", os.path.expanduser('~/.cutlass_test.ini')]

        parser = ConfigParser.ConfigParser()
        successfullyReadFiles = parser.read(config_paths);

        if len(successfullyReadFiles) == 0:
            raise Exception("Unable to find .cutlass_test.ini in cwd or in home directory")

        section = 'cutlass'
        host = parser.get(section, 'host')
        port = parser.get(section, 'port')
        username = parser.get(section, 'username')
        password = parser.get(section, 'password')
        ssl = parser.getboolean(section, 'ssl')

        #print("{} - {} - {} - {} - {}".format(host, port, username, password, ssl))

        if (host is None or port is None or username is None or password is None):
            raise Exception("Missing configuration parameters in .cutlass_test.ini.")

        session = iHMPSession(username, password, server=host, port=port, ssl=ssl)

        return session
Пример #59
0
#!/usr/bin/env python

import unittest
import json
import sys

from cutlass import iHMPSession
from cutlass import Study
from cutlass import MIXS, MixsException

session = iHMPSession("foo", "bar")

class StudyTest(unittest.TestCase):

    def testImport(self):
        success = False
        try:
            from cutlass import Study
            success = True
        except:
            pass

        self.failUnless(success)
        self.failIf(Study is None)

    def testSessionCreate(self):
        success = False
        study = None

        try:
            study = session.create_study()
Пример #60
0
class auth():
    username = load_string_from_file('auth/username.txt')
    password = load_string_from_file('auth/password.txt')

def dprint(*args):
    """dprint is print with a prefix"""
    pref='  -> '
    print(pref,
          ' '.join([str(arg) for arg in args])
         )

import re

try:
    log = log_it()
    session = iHMPSession(auth.username, auth.password)
    osdf = session.get_osdf()
    info = osdf.get_info()
    print(info)
    # info = session.get_session()
    # info = session.port
    # print(info)
except Exception as e:
    raise e

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def query_all_oql(session, namespace, node_type, query):
    """use oql_query_all_pages for complete sets of results
    [ Requires pre-existing 'iHMPSession'! ]
    """
    cumulative = session.get_osdf().oql_query_all_pages(namespace, query)