Ejemplo n.º 1
0
def run(description):
    parser = argparse.ArgumentParser(
        description='Renames sequences in a file, calling them 1,2,3... etc',
        usage='fastaq enumerate_names [options] <infile> <outfile>')
    parser.add_argument('--start_index',
                        type=int,
                        help='Starting number [%(default)s]',
                        default=1)
    parser.add_argument(
        '--rename_file',
        help='If used, will write a file of old name to new name')
    parser.add_argument(
        '--keep_suffix',
        action='store_true',
        help='Use this to keep a /1 or /2 suffix at the end of each name')
    parser.add_argument('--suffix',
                        help='Add the given string to the end of every name',
                        default=None)
    parser.add_argument('infile', help='Name of fasta/q file to be read')
    parser.add_argument('outfile', help='Name of output fasta/q file')
    options = parser.parse_args()
    tasks.enumerate_names(options.infile,
                          options.outfile,
                          start_index=options.start_index,
                          keep_illumina_suffix=options.keep_suffix,
                          rename_file=options.rename_file,
                          suffix=options.suffix)
Ejemplo n.º 2
0
    def test_enumerate_names(self):
        '''Test enomereate_names works with all options'''
        outfile = 'tmp.enumerate_seqs.fa'
        rename_out = outfile + '.rename'
        tasks.enumerate_names(
            os.path.join(data_dir, 'sequences_test_enumerate_names.fa'),
            outfile)
        self.assertTrue(
            filecmp.cmp(
                os.path.join(data_dir,
                             'sequences_test_enumerate_names.fa.out.start.1'),
                outfile))
        tasks.enumerate_names(os.path.join(
            data_dir, 'sequences_test_enumerate_names.fa'),
                              outfile,
                              rename_file=rename_out)
        self.assertTrue(
            filecmp.cmp(
                os.path.join(data_dir,
                             'sequences_test_enumerate_names.fa.out.start.1'),
                outfile))
        self.assertTrue(
            filecmp.cmp(
                os.path.join(
                    data_dir,
                    'sequences_test_enumerate_names.fa.out.start.1.rename_file'
                ), rename_out))
        tasks.enumerate_names(os.path.join(
            data_dir, 'sequences_test_enumerate_names.fa'),
                              outfile,
                              start_index=2)
        self.assertTrue(
            filecmp.cmp(
                os.path.join(data_dir,
                             'sequences_test_enumerate_names.fa.out.start.2'),
                outfile))
        tasks.enumerate_names(os.path.join(
            data_dir, 'sequences_test_enumerate_names.fa'),
                              outfile,
                              keep_illumina_suffix=True)
        self.assertTrue(
            filecmp.cmp(
                os.path.join(
                    data_dir,
                    'sequences_test_enumerate_names.fa.out.keep_suffix'),
                outfile))

        tasks.enumerate_names(os.path.join(
            data_dir, 'sequences_test_enumerate_names.fa'),
                              outfile,
                              suffix='.SUFFIX')
        self.assertTrue(
            filecmp.cmp(os.path.join(
                data_dir, 'sequences_test_enumerate_names.fa.out.add_suffix'),
                        outfile,
                        shallow=False))
        os.unlink(outfile)
        os.unlink(rename_out)
Ejemplo n.º 3
0
def run(description):
    parser = argparse.ArgumentParser(
    description = 'Renames sequences in a file, calling them 1,2,3... etc',
    usage = 'fastaq enumerate_names [options] <infile> <outfile>')
    parser.add_argument('--start_index', type=int, help='Starting number [%(default)s]', default=1)
    parser.add_argument('--rename_file', help='If used, will write a file of old name to new name')
    parser.add_argument('--keep_suffix', action='store_true', help='Use this to keep a /1 or /2 suffix at the end of each name')
    parser.add_argument('--suffix', help='Add the given string to the end of every name', default=None)
    parser.add_argument('infile', help='Name of fasta/q file to be read')
    parser.add_argument('outfile', help='Name of output fasta/q file')
    options = parser.parse_args()
    tasks.enumerate_names(options.infile,
        options.outfile,
        start_index=options.start_index,
        keep_illumina_suffix=options.keep_suffix,
        rename_file=options.rename_file,
        suffix=options.suffix)
Ejemplo n.º 4
0
    def test_enumerate_names(self):
        '''Test enomereate_names works with all options'''
        outfile = 'tmp.enumerate_seqs.fa'
        rename_out = outfile + '.rename'
        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile)
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1'), outfile))
        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, rename_file=rename_out)
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1'), outfile))
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1.rename_file'), rename_out))
        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, start_index=2)
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.2'), outfile))
        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, keep_illumina_suffix=True)
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.keep_suffix'), outfile))

        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, suffix='.SUFFIX')
        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.add_suffix'), outfile, shallow=False))
        os.unlink(outfile)
        os.unlink(rename_out)