def test_use_hp_information_conflicts(self, use_hp_information,
                                       make_examples_extra_args,
                                       has_conflict):
     """Confirms that PacBio use_hp_information can conflict with HP args."""
     FLAGS.model_type = 'PACBIO'
     FLAGS.ref = 'your_ref'
     FLAGS.sample_name_child = 'your_sample_child'
     FLAGS.sample_name_parent1 = 'your_sample_parent1'
     FLAGS.sample_name_parent2 = 'your_sample_parent2'
     FLAGS.reads_child = 'your_bam_child'
     FLAGS.reads_parent1 = 'your_bam_parent1'
     FLAGS.reads_parent2 = 'your_bam_parent2'
     FLAGS.output_vcf_child = 'your_vcf_child'
     FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
     FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
     FLAGS.output_gvcf_child = 'your_gvcf_child'
     FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
     FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
     FLAGS.num_shards = 64
     FLAGS.regions = None
     FLAGS.use_hp_information = use_hp_information
     FLAGS.make_examples_extra_args = make_examples_extra_args
     if has_conflict:
         with six.assertRaisesRegex(self, ValueError,
                                    'conflicts with other flags'):
             run_deeptrio.create_all_commands('/tmp/deeptrio_tmp_output')
     else:
         # Otherwise, the command should run without rasing errors.
         run_deeptrio.create_all_commands('/tmp/deeptrio_tmp_output')
    def test_postprocess_variants_duplicate_extra_args(
            self, vcf_stats_report, postprocess_variants_extra_args,
            expected_vcf_stats_report):
        FLAGS.model_type = 'WGS'
        FLAGS.ref = 'your_ref'
        FLAGS.sample_name_child = 'your_sample_child'
        FLAGS.sample_name_parent1 = 'your_sample_parent1'
        FLAGS.sample_name_parent2 = 'your_sample_parent2'
        FLAGS.reads_child = 'your_bam_child'
        FLAGS.reads_parent1 = 'your_bam_parent1'
        FLAGS.reads_parent2 = 'your_bam_parent2'
        FLAGS.output_vcf_child = 'your_vcf_child'
        FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
        FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
        FLAGS.output_gvcf_child = 'your_gvcf_child'
        FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
        FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
        FLAGS.num_shards = 64
        FLAGS.vcf_stats_report = vcf_stats_report
        FLAGS.postprocess_variants_extra_args = postprocess_variants_extra_args
        _, commands_post_process = run_deeptrio.create_all_commands(
            '/tmp/deeptrio_tmp_output')

        self.assertEqual(
            commands_post_process[0],
            'time /opt/deepvariant/bin/postprocess_variants '
            '--ref "your_ref" '
            '--infile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_child.tfrecord.gz" '
            '--outfile "your_vcf_child" '
            '--nonvariant_site_tfrecord_path '
            '"/tmp/deeptrio_tmp_output/[email protected]" '
            '--gvcf_outfile "your_gvcf_child" '
            '%s' % expected_vcf_stats_report)
    def test_call_variants_extra_args(self, call_variants_extra_args,
                                      expected_args):
        FLAGS.model_type = 'WGS'
        FLAGS.ref = 'your_ref'
        FLAGS.sample_name_child = 'your_sample_child'
        FLAGS.sample_name_parent1 = 'your_sample_parent1'
        FLAGS.sample_name_parent2 = 'your_sample_parent2'
        FLAGS.reads_child = 'your_bam_child'
        FLAGS.reads_parent1 = 'your_bam_parent1'
        FLAGS.reads_parent2 = 'your_bam_parent2'
        FLAGS.output_vcf_child = 'your_vcf_child'
        FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
        FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
        FLAGS.output_gvcf_child = 'your_gvcf_child'
        FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
        FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
        FLAGS.num_shards = 64
        FLAGS.call_variants_extra_args = call_variants_extra_args
        commands, _ = run_deeptrio.create_all_commands(
            '/tmp/deeptrio_tmp_output')

        self.assertEqual(
            commands[1], 'time /opt/deepvariant/bin/call_variants '
            '--outfile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_child.tfrecord.gz" '
            '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
            '--checkpoint "/opt/models/deeptrio/wgs/child/model.ckpt" '
            '%s' % expected_args)
    def test_make_examples_regions(self, regions, expected_args):
        FLAGS.model_type = 'WGS'
        FLAGS.ref = 'your_ref'
        FLAGS.sample_name_child = 'your_sample_child'
        FLAGS.sample_name_parent1 = 'your_sample_parent1'
        FLAGS.sample_name_parent2 = 'your_sample_parent2'
        FLAGS.reads_child = 'your_bam_child'
        FLAGS.reads_parent1 = 'your_bam_parent1'
        FLAGS.reads_parent2 = 'your_bam_parent2'
        FLAGS.output_vcf_child = 'your_vcf_child'
        FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
        FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
        FLAGS.num_shards = 64
        FLAGS.regions = regions
        commands, _ = run_deeptrio.create_all_commands(
            '/tmp/deeptrio_tmp_output')

        self.assertEqual(
            commands[0], 'time seq 0 63 | parallel -q --halt 2 --line-buffer '
            '/opt/deepvariant/bin/deeptrio/make_examples --mode calling '
            '--ref "your_ref" --reads_parent1 "your_bam_parent1" '
            '--reads_parent2 "your_bam_parent2" '
            '--reads "your_bam_child" '
            '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
            '--sample_name "your_sample_child" '
            '--sample_name_parent1 "your_sample_parent1" '
            '--sample_name_parent2 "your_sample_parent2" '
            '%s '
            '--task {}' % expected_args)
 def test_pacbio_args_overwrite(self, make_examples_extra_args,
                                expected_args):
     """Confirms that adding extra flags can overwrite the default from mode."""
     FLAGS.model_type = 'PACBIO'
     FLAGS.ref = 'your_ref'
     FLAGS.sample_name_child = 'your_sample_child'
     FLAGS.sample_name_parent1 = 'your_sample_parent1'
     FLAGS.sample_name_parent2 = 'your_sample_parent2'
     FLAGS.reads_child = 'your_bam_child'
     FLAGS.reads_parent1 = 'your_bam_parent1'
     FLAGS.reads_parent2 = 'your_bam_parent2'
     FLAGS.output_vcf_child = 'your_vcf_child'
     FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
     FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
     FLAGS.output_gvcf_child = 'your_gvcf_child'
     FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
     FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
     FLAGS.num_shards = 64
     FLAGS.regions = None
     FLAGS.make_examples_extra_args = make_examples_extra_args
     commands, _ = run_deeptrio.create_all_commands(
         '/tmp/deeptrio_tmp_output')
     self.assertEqual(
         commands[0], 'time seq 0 63 | parallel -q --halt 2 --line-buffer '
         '/opt/deepvariant/bin/deeptrio/make_examples --mode calling '
         '--ref "your_ref" --reads_parent1 "your_bam_parent1" '
         '--reads_parent2 "your_bam_parent2" '
         '--reads "your_bam_child" '
         '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
         '--sample_name "your_sample_child" '
         '--sample_name_parent1 "your_sample_parent1" '
         '--sample_name_parent2 "your_sample_parent2" '
         '%s'
         '--task {}' % expected_args)
 def test_duo_make_examples_commands_with_types(self, model_type,
                                                extra_args_plus_gvcf):
     FLAGS.model_type = model_type
     FLAGS.ref = 'your_ref'
     FLAGS.reads_child = 'your_bam_child'
     FLAGS.reads_parent1 = 'your_bam_parent1'
     FLAGS.sample_name_child = 'your_sample_child'
     FLAGS.sample_name_parent1 = 'your_sample_parent1'
     FLAGS.output_vcf_child = 'your_vcf_child'
     FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
     FLAGS.output_gvcf_child = 'your_gvcf_child'
     FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
     FLAGS.output_gvcf_merged = 'your_gvcf_merged'
     FLAGS.num_shards = 64
     commands, _ = run_deeptrio.create_all_commands(
         '/tmp/deeptrio_tmp_output')
     self.assertEqual(
         commands[0], 'time seq 0 63 '
         '| parallel -q --halt 2 --line-buffer '
         '/opt/deepvariant/bin/deeptrio/make_examples '
         '--mode calling '
         '--ref "your_ref" '
         '--reads_parent1 "your_bam_parent1" '
         '--reads "your_bam_child" '
         '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
         '--sample_name "your_sample_child" '
         '--sample_name_parent1 "your_sample_parent1" '
         '%s'
         '--task {}' % extra_args_plus_gvcf)
Beispiel #7
0
 def _create_all_commands_and_check_stdout(self, expected_stdout=None):
   with mock.patch('sys.stdout', new_callable=io.StringIO) as mock_stdout:
     commands, postprocess_cmds = run_deeptrio.create_all_commands(
         '/tmp/deeptrio_tmp_output')
     # Confirm that these basic commands don't have extra messages printed out
     # to stdout.
     if expected_stdout is None:
       self.assertEmpty(mock_stdout.getvalue())
     else:
       self.assertEqual(mock_stdout.getvalue(), expected_stdout)
   return commands, postprocess_cmds
    def test_duo_call_variants_postprocess_variants_commands(self, model_type):
        FLAGS.model_type = model_type
        FLAGS.ref = 'your_ref'
        FLAGS.reads_child = 'your_bam_child'
        FLAGS.reads_parent1 = 'your_bam_parent1'
        FLAGS.sample_name_child = 'your_sample_child'
        FLAGS.sample_name_parent1 = 'your_sample_parent1'
        FLAGS.output_vcf_child = 'your_vcf_child'
        FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
        FLAGS.output_gvcf_child = 'your_gvcf_child'
        FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
        FLAGS.output_gvcf_merged = 'your_gvcf_merged'
        FLAGS.num_shards = 64
        commands, post_process_commands = run_deeptrio.create_all_commands(
            '/tmp/deeptrio_tmp_output')

        self.assertEqual(
            commands[1], 'time /opt/deepvariant/bin/call_variants '
            '--outfile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_child.tfrecord.gz" '
            '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
            '--checkpoint "/opt/models/deeptrio/{}/child/model.ckpt"'.format(
                model_type.lower()))
        self.assertEqual(
            commands[2], 'time /opt/deepvariant/bin/call_variants '
            '--outfile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_parent1.tfrecord.gz" '
            '--examples "/tmp/deeptrio_tmp_output/[email protected]" '
            '--checkpoint "/opt/models/deeptrio/{}/parent/model.ckpt"'.format(
                model_type.lower()))
        self.assertEqual(
            post_process_commands[0],
            'time /opt/deepvariant/bin/postprocess_variants '
            '--ref "your_ref" '
            '--infile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_child.tfrecord.gz" '
            '--outfile "your_vcf_child" '
            '--nonvariant_site_tfrecord_path '
            '"/tmp/deeptrio_tmp_output/[email protected]" '
            '--gvcf_outfile "your_gvcf_child"')
        self.assertEqual(
            post_process_commands[1],
            'time /opt/deepvariant/bin/postprocess_variants '
            '--ref "your_ref" '
            '--infile '
            '"/tmp/deeptrio_tmp_output/call_variants_output_parent1.tfrecord.gz" '
            '--outfile "your_vcf_parent1" '
            '--nonvariant_site_tfrecord_path '
            '"/tmp/deeptrio_tmp_output/[email protected]" '
            '--gvcf_outfile "your_gvcf_parent1"')
        # pylint: disable=g-generic-assert
        self.assertLen(commands, 3)
        self.assertLen(post_process_commands, 2)
 def test_use_hp_information_only_with_pacbio(self, model_type):
     """Confirms use_hp_information only works for."""
     FLAGS.model_type = model_type
     FLAGS.ref = 'your_ref'
     FLAGS.sample_name_child = 'your_sample_child'
     FLAGS.sample_name_parent1 = 'your_sample_parent1'
     FLAGS.sample_name_parent2 = 'your_sample_parent2'
     FLAGS.reads_child = 'your_bam_child'
     FLAGS.reads_parent1 = 'your_bam_parent1'
     FLAGS.reads_parent2 = 'your_bam_parent2'
     FLAGS.output_vcf_child = 'your_vcf_child'
     FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
     FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
     FLAGS.output_gvcf_child = 'your_gvcf_child'
     FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
     FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
     FLAGS.num_shards = 64
     FLAGS.regions = None
     FLAGS.use_hp_information = True
     with six.assertRaisesRegex(
             self, ValueError, '--use_hp_information can only be used with '
             '--model_type="PACBIO"'):
         run_deeptrio.create_all_commands('/tmp/deeptrio_tmp_output')
Beispiel #10
0
 def test_make_examples_extra_args_invalid(self):
   FLAGS.model_type = 'WGS'
   FLAGS.ref = 'your_ref'
   FLAGS.sample_name_child = 'your_sample_child'
   FLAGS.sample_name_parent1 = 'your_sample_parent1'
   FLAGS.sample_name_parent2 = 'your_sample_parent2'
   FLAGS.reads_child = 'your_bam_child'
   FLAGS.reads_parent1 = 'your_bam_parent1'
   FLAGS.reads_parent2 = 'your_bam_parent2'
   FLAGS.output_vcf_child = 'your_vcf_child'
   FLAGS.output_vcf_parent1 = 'your_vcf_parent1'
   FLAGS.output_vcf_parent2 = 'your_vcf_parent2'
   FLAGS.output_gvcf_child = 'your_gvcf_child'
   FLAGS.output_gvcf_parent1 = 'your_gvcf_parent1'
   FLAGS.output_gvcf_parent2 = 'your_gvcf_parent2'
   FLAGS.num_shards = 64
   FLAGS.make_examples_extra_args = 'keep_secondary_alignments'
   with six.assertRaisesRegex(self, ValueError, 'not enough values to unpack'):
     _, _ = run_deeptrio.create_all_commands('/tmp/deeptrio_tmp_output')