def test_it_reads_the_same_data_it_writes(self):
    with TemporaryDirectory(suffix="fjdksnfsdk") as tmpdir:
        self.expected["output_folder"] = tmpdir

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, "test_run_name-config.xml"))

        self.assertDictEqual(self.expected, observed)
示例#2
0
def test_it_reads_the_same_data_it_writes(self):
    with TemporaryDirectory(suffix='fjdksnfsdk') as tmpdir:
        self.expected['output_folder'] = tmpdir

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, 'test_run_name-config.xml'))

        self.assertDictEqual(self.expected, observed)
def test_it_stores_vcfs(self):
    with TemporaryDirectory() as tmpdir:
        self.expected["output_folder"] = tmpdir

        self.expected["vcfs"] = [("foo", "bar")]

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, "test_run_name-config.xml"))

        self.assertDictEqual(self.expected, observed)
def test_it_should_warn_when_the_read_element_does_not_contain_read_files(self):
    with TemporaryDirectory() as tmpdir:
        self.expected["output_folder"] = tmpdir

        self.expected["reads"] = [("not_a_valid_read_file", "", "")]

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, "test_run_name-config.xml"))

        self.assertDictEqual(self.expected, observed)
示例#5
0
def test_it_stores_vcfs(self):
    with TemporaryDirectory() as tmpdir:
        self.expected['output_folder'] = tmpdir

        self.expected['vcfs'] = [
            ('foo', 'bar')
        ]

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, 'test_run_name-config.xml'))

        self.assertDictEqual(self.expected, observed)
示例#6
0
def test_it_should_warn_when_the_read_element_does_not_contain_read_files(self):
    with TemporaryDirectory() as tmpdir:
        self.expected['output_folder'] = tmpdir

        self.expected['reads'] = [
            ('not_a_valid_read_file', '', '')
        ]

        configuration_parser.write_config(self.expected)

        observed = configuration_parser.parse_config(os.path.join(tmpdir, 'test_run_name-config.xml'))

        self.assertDictEqual(self.expected, observed)
示例#7
0
文件: nasp.py 项目: wangdi2014/NASP
def main():
    import sys
    import nasp.dispatcher as dispatcher
    import nasp.configuration_parser as configuration_parser

    # This is hack to forward commands to gonasp
    if len(sys.argv) > 1 and sys.argv[1] in [
            'help', 'duplicates', 'frankenfasta', 'matrix', 'export'
    ]:
        if sys.argv[1] == 'help' or any(
                arg in ['-h', '-help', '--help']
                for arg in sys.argv) or len(sys.argv) < 3:
            print(
                "Requesting nasp internal command usage message. Enter 'nasp --help' for the nasp pipeline usage message."
            )
            print(
                "Unlike the nasp pipeline, these commands will not be automatically submitted to your job manager"
            )
        import subprocess
        subprocess.call([gonasp_path()] + sys.argv[1:])
        return

    commandline_args = _parse_args()
    if commandline_args.config:
        configuration = configuration_parser.parse_config(
            commandline_args.config)
        output_folder = configuration["output_folder"]
        if os.path.exists(output_folder):
            response = input(
                "\nOutput folder %s already exists!\nFiles in it may be overwritten!\nShould we continue anyway [N]? "
                % output_folder)
            if not re.match('^[Yy]', response):
                print("Operation cancelled!")
                quit()
        else:
            os.makedirs(output_folder)
        logfile = os.path.join(output_folder, "runlog.txt")
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(levelname)-8s %(message)s',
                            datefmt='%m/%d/%Y %H:%M:%S',
                            filename=logfile,
                            filemode='w')
    else:
        configuration = _get_user_input(commandline_args.reference_fasta,
                                        commandline_args.output_folder)
    configuration_parser.write_config(configuration)
    dispatcher.begin(configuration)
示例#8
0
def main():
    import sys
    import nasp.dispatcher as dispatcher
    import nasp.configuration_parser as configuration_parser

    # This is hack to forward commands to gonasp
    if len(sys.argv) > 1 and sys.argv[1] in ['help', 'duplicates', 'frankenfasta', 'matrix', 'export']:
        if sys.argv[1] == 'help' or any(arg in ['-h', '-help', '--help'] for arg in sys.argv) or len(sys.argv) < 3:
            print("Requesting nasp internal command usage message. Enter 'nasp --help' for the nasp pipeline usage message.")
            print("Unlike the nasp pipeline, these commands will not be automatically submitted to your job manager")
        import subprocess
        subprocess.call([gonasp_path()] + sys.argv[1:])
        return

    commandline_args = _parse_args()
    if commandline_args.config:
        configuration = configuration_parser.parse_config(commandline_args.config)
        output_folder = configuration["output_folder"]
        if os.path.exists(output_folder):
            response = input(
                "\nOutput folder %s already exists!\nFiles in it may be overwritten!\nShould we continue anyway [N]? " % output_folder)
            if not re.match('^[Yy]', response):
                print("Operation cancelled!")
                quit()
        else:
            os.makedirs(output_folder)
        logfile = os.path.join(output_folder, "runlog.txt")
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(levelname)-8s %(message)s',
                            datefmt='%m/%d/%Y %H:%M:%S',
                            filename=logfile,
                            filemode='w')
    else:
        configuration = _get_user_input(commandline_args.reference_fasta, commandline_args.output_folder)
    configuration_parser.write_config(configuration)
    dispatcher.begin(configuration)