Beispiel #1
0
 def setUp(self):
     self.temp_d = tempfile.TemporaryDirectory()
     os.chdir(self.temp_d.name)
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = self.temp_d.name
     TenxApp.config['TENX_ASM_CORES'] = "2"
     TenxApp.config['TENX_ASM_MEM'] = "2"
Beispiel #2
0
    def test1_script_template(self):
        with self.assertRaisesRegex(
                Exception,
                "Scripts directory \(TENX_SCRIPTS_PATH\) is not set in tenx config!"
        ):
            TenxApp.load_script_template('blah')

        TenxApp.config['TENX_SCRIPTS_PATH'] = self.scripts_path.name
        with self.assertRaisesRegex(
                Exception, "Failed to find script template file: {}".format(
                    os.path.join(TenxApp.config['TENX_SCRIPTS_PATH'],
                                 'blah.jinja'))):
            TenxApp.load_script_template('blah')

        script_template = TenxApp.load_script_template('foo')
        self.assertIsNotNone(script_template)
Beispiel #3
0
    def test1_slack(self, test_patch):
        TenxApp()
        TenxApp.config['TENX_NOTIFICATIONS_SLACK'] = "https://slack.com"
        notok_response = NotificationsTest.Response(ok=False)
        test_patch.return_value = notok_response
        with self.assertRaisesRegex(Exception, 'Slack POST failed for {}'.format(TenxApp.config['TENX_NOTIFICATIONS_SLACK'])):
            notifications.slack(message="Hello World!")

        ok_response = NotificationsTest.Response(ok=True)
        test_patch.return_value = ok_response
        notifications.slack(message="Hello World!")
Beispiel #4
0
 def setUp(self):
     self.temp_d = tempfile.TemporaryDirectory()
     self.rurl = "gs://data"
     os.chdir(self.temp_d.name)
     sample = TenxSample(name='TESTER', base_path=self.temp_d.name)
     self.asm = sample.assembly()
     rsample = TenxSample(name='TESTER', base_path=self.rurl)
     self.remote_asm = rsample.assembly()
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = self.temp_d.name
     TenxApp.config['TENX_REMOTE_URL'] = self.rurl
Beispiel #5
0
 def setUp(self):
     self.temp_d = tempfile.TemporaryDirectory()
     self.ref = TenxReference(name='refdata-GRCh38-2.1.0')
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = self.temp_d.name
     TenxApp.config['TENX_REMOTE_URL'] = 'gs://data'
     TenxApp.config['TENX_REMOTE_REFS_URL'] = 'gs://data/references'
     TenxApp.config['TENX_ALN_MODE'] = 'local'
     TenxApp.config['TENX_ALN_CORES'] = '1'
     TenxApp.config['TENX_ALN_MEM'] = '6'
     TenxApp.config['TENX_ALN_VCMODE'] = 'freebayes'
Beispiel #6
0
    def test_init(self):
        # init w/o config
        tenxapp = TenxApp()
        self.assertIsNotNone(TenxApp.config)

        # re-init w/ config
        TenxApp.config = None
        self.assertIsNone(TenxApp.config)

        conf_f = tempfile.NamedTemporaryFile()
        config = {
            "environment": "test",
            "TENX_SCRIPTS_PATH": "tests/test_app",
            "TENX_NOTIFICATIONS_SLACK": "https://slack.com",
        }
        conf_f.write(yaml.dump(config).encode())
        conf_f.flush()

        tenxapp = TenxApp(conf_f.name)
        self.assertIsNotNone(tenxapp)
        self.assertDictEqual(tenxapp.config, config)
Beispiel #7
0
    def setUp(self):
        self.temp_d = tempfile.TemporaryDirectory()
        if TenxApp.config is None: TenxApp()
        TenxApp.config['TENX_DATA_PATH'] = self.temp_d.name
        TenxApp.config['TENX_REMOTE_URL'] = 'gs://data'

        self.lsample = TenxSample(
            base_path=TenxApp.config.get("TENX_DATA_PATH"), name='TEST-001')
        os.makedirs(self.lsample.reads_path)
        with open(os.path.join(self.lsample.reads_path, 'read1.fastq'),
                  'w') as f:
            f.write("FASTQ\n")  # a fastq file
        self.rsample = TenxSample(
            base_path=TenxApp.config.get("TENX_REMOTE_URL"), name='TEST-001')
Beispiel #8
0
    def setUp(self):
        self.temp_d = tempfile.TemporaryDirectory()
        if TenxApp.config is None: TenxApp()
        TenxApp.config = {
                "TENX_DATA_PATH": self.temp_d.name,
                "TENX_REMOTE_URL": "gs://data",
                "TENX_REMOTE_REFS_URL": "gs://data/refs",
                "TENX_ALN_VCMODE": "freebayes",
                "TENX_ALN_MODE": "wgs",
                "TENX_ALN_MEM": "1",
                "TENX_ALN_CORES": "1",
                }

        sample = TenxSample(name="__SAMPLE__", base_path=TenxApp.config["TENX_DATA_PATH"])
        ref = TenxReference(name="__REF__")
        self.aln= sample.alignment(ref)
        rsample = TenxSample(name="__SAMPLE__", base_path=TenxApp.config["TENX_REMOTE_URL"])
        self.raln = rsample.alignment(ref)

        os.chdir(self.temp_d.name)
        os.makedirs(self.aln.outs_path)
        os.makedirs(os.path.join(TenxApp.config["TENX_DATA_PATH"], "references"))
Beispiel #9
0
 def setUp(self):
     TenxApp()
     TenxApp.config = {"TENX_REMOTE_URL": "gs://data"}
Beispiel #10
0
 def test_init_fails(self):
     if TenxApp.config is None: TenxApp()
     TenxApp.config = None
     with self.assertRaisesRegex(IOError, "No such file or directory"):
         TenxApp("/tenx.yaml")
Beispiel #11
0
 def setUp(self):
     TenxApp()
     self.scripts_path = tempfile.TemporaryDirectory()
     with open(os.path.join(self.scripts_path.name, "foo.jinja"), "w") as f:
         f.write("FOO JINJA TEMPLATE")
Beispiel #12
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     os.chdir(self.tempdir)
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = self.tempdir
     TenxApp.config['TENX_REMOTE_REFS_URL'] = 'gs://data/references'
Beispiel #13
0
 def setUp(self):
     self.temp_d = tempfile.TemporaryDirectory()
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = self.temp_d.name
     TenxApp.config['TENX_REMOTE_URL'] = 'gs://data'
Beispiel #14
0
 def setUp(self):
     if TenxApp.config is None: TenxApp()
     TenxApp.config['TENX_DATA_PATH'] = "/mnt/disks/data"
     TenxApp.config['TENX_REMOTE_URL'] = "gs://data"
Beispiel #15
0
def cli():
    """
    10X CLI
    """
    TenxApp(os.environ.get('TENX_CONFIG_FILE', None))
    pass