Пример #1
0
 def test_programs(self):
     """Identify programs and versions used in analysis.
     """
     with make_workdir() as workdir:
         config = load_config(
             get_post_process_yaml(self.automated_dir, workdir))
         print programs._get_versions(config)
Пример #2
0
 def test_1_parallel_vcf_combine(self):
     """Parallel combination of VCF files, split by chromosome.
     """
     files = [
         os.path.join(self.var_dir, "S1-variants.vcf"),
         os.path.join(self.var_dir, "S2-variants.vcf")
     ]
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq",
                             "hg19.fa")
     with make_workdir() as workdir:
         config = load_config(
             get_post_process_yaml(self.automated_dir, workdir))
         config["algorithm"] = {}
     region_dir = os.path.join(self.var_dir, "S1_S2-combined-regions")
     if os.path.exists(region_dir):
         shutil.rmtree(region_dir)
     if os.path.exists(self.combo_file):
         os.remove(self.combo_file)
     with prun.start({
             "type": "local",
             "cores": 1
     }, [[config]], config) as run_parallel:
         vcfutils.parallel_combine_variants(files, self.combo_file,
                                            ref_file, config, run_parallel)
     for fname in files:
         if os.path.exists(fname + ".gz"):
             subprocess.check_call(["gunzip", fname + ".gz"])
         if os.path.exists(fname + ".gz.tbi"):
             os.remove(fname + ".gz.tbi")
Пример #3
0
 def test_2_vcf_exclusion(self):
     """Exclude samples from VCF files.
     """
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.automated_dir, workdir))
         config["algorithm"] = {}
     out_file = utils.append_stem(self.combo_file, "-exclude")
     to_exclude = ["S1"]
     if os.path.exists(out_file):
         os.remove(out_file)
     vcfutils.exclude_samples(self.combo_file, out_file, to_exclude, ref_file, config)
Пример #4
0
 def test_2_vcf_exclusion(self):
     """Exclude samples from VCF files.
     """
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.data_dir, workdir))
         config["algorithm"] = {}
     out_file = utils.append_stem(self.combo_file, "-exclude")
     to_exclude = ["S1"]
     if os.path.exists(out_file):
         os.remove(out_file)
     vcfutils.exclude_samples(self.combo_file, out_file, to_exclude, ref_file, config)
Пример #5
0
 def setUp(self):
     make_workdir()
     # Make up some barcode numbers
     self.workdir = os.path.join(os.path.dirname(__file__), "test_automated_output")
     self.data_dir = os.path.join(os.path.dirname(__file__), "data", "automated")
     
     # Parse the run_info
     run_info_file = os.path.join(self.data_dir, "run_info-gdocs.yaml")
     with open(run_info_file) as fh:
         self.run_info = yaml.load(fh)
         
     # Make up bogus run names
     self.runname = ("111014_SN0000_0001_AB0AAAACXX","111014_SN0000_0002_BB0AAAACXX")
     
     # Create the run directories (create them if necessary)
     for name in self.runname:
         analysisdir = os.path.join(self.workdir, name)
         if os.path.exists(analysisdir):
             shutil.rmtree(analysisdir)
         os.makedirs(analysisdir)
         self._make_bc_metrics(name,analysisdir)
Пример #6
0
    def setUp(self):
        make_workdir()
        # Make up some barcode numbers
        self.workdir = os.path.join(os.path.dirname(__file__), "test_automated_output")
        self.data_dir = os.path.join(os.path.dirname(__file__), "data", "automated")

        # Parse the run_info
        self.run_info_file = os.path.join(self.data_dir, "run_info-gdocs.yaml")
        with open(self.run_info_file) as fh:
            self.run_info = yaml.load(fh)

        # Make up bogus run names
        self.runname = ("111014_SN0000_0001_AB0AAAACXX", "111014_SN0000_0002_BB0AAAACXX")

        # Create the run directories (create them if necessary)
        for name in self.runname:
            analysisdir = os.path.join(self.workdir, name)
            if os.path.exists(analysisdir):
                shutil.rmtree(analysisdir)
            os.makedirs(analysisdir)
            self._make_bc_metrics(name, analysisdir)
            self._make_qc_metrics(name, analysisdir)
Пример #7
0
 def test_3_vcf_split_combine(self):
     """Split a VCF file into SNPs and indels, then combine back together.
     """
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.automated_dir, workdir))
         config["algorithm"] = {}
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     fname = os.path.join(self.var_dir, "S1-variants.vcf")
     snp_file, indel_file = vcfutils.split_snps_indels(fname, ref_file, config)
     merge_file = "%s-merge%s.gz" % os.path.splitext(fname)
     vcfutils.combine_variant_files([snp_file, indel_file], merge_file, ref_file,
                                    config)
     for f in [snp_file, indel_file, merge_file]:
         self._remove_vcf(f)
Пример #8
0
 def test_3_vcf_split_combine(self):
     """Split a VCF file into SNPs and indels, then combine back together.
     """
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.data_dir, workdir))
         config["algorithm"] = {}
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     fname = os.path.join(self.var_dir, "S1-variants.vcf")
     snp_file, indel_file = vcfutils.split_snps_indels(fname, ref_file, config)
     merge_file = "%s-merge%s.gz" % os.path.splitext(fname)
     vcfutils.combine_variant_files([snp_file, indel_file], merge_file, ref_file,
                                    config)
     for f in [snp_file, indel_file, merge_file]:
         self._remove_vcf(f)
Пример #9
0
 def test_2_vcf_exclusion(self):
     """Exclude samples from VCF files.
     """
     # Be back compatible with 0.7.6 -- remove after 0.7.7 release
     if prun is None:
         return
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.data_dir, workdir))
         config["algorithm"] = {}
     out_file = utils.append_stem(self.combo_file, "-exclude")
     to_exclude = ["S1"]
     if os.path.exists(out_file):
         os.remove(out_file)
     vcfutils.exclude_samples(self.combo_file, out_file, to_exclude, ref_file, config)
Пример #10
0
 def test_1_parallel_vcf_combine(self):
     """Parallel combination of VCF files, split by chromosome.
     """
     files = [os.path.join(self.var_dir, "S1-variants.vcf"), os.path.join(self.var_dir, "S2-variants.vcf")]
     ref_file = os.path.join(self.data_dir, "genomes", "hg19", "seq", "hg19.fa")
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.automated_dir, workdir))
         config["algorithm"] = {}
     region_dir = os.path.join(self.var_dir, "S1_S2-combined-regions")
     if os.path.exists(region_dir):
         shutil.rmtree(region_dir)
     if os.path.exists(self.combo_file):
         os.remove(self.combo_file)
     with prun.start({"type": "local", "cores": 1}, [[config]], config) as run_parallel:
         vcfutils.parallel_combine_variants(files, self.combo_file, ref_file, config, run_parallel)
     for fname in files:
         if os.path.exists(fname + ".gz"):
             subprocess.check_call(["gunzip", fname + ".gz"])
         if os.path.exists(fname + ".gz.tbi"):
             os.remove(fname + ".gz.tbi")
Пример #11
0
 def test_programs(self):
     """Identify programs and versions used in analysis.
     """
     with make_workdir() as workdir:
         config = load_config(get_post_process_yaml(self.data_dir, workdir))
         print programs._get_versions(config)