Beispiel #1
0
 def test_reporting_relationships(self, cfg_pth):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
     bedset_id = bbc.bedset.retrieve(
         record_identifier="bedset1", result_identifier="id"
     )
     bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
Beispiel #2
0
 def test_nonunique_digest_insert_error(
     self, cfg_pth, test_data_bed, test_data_bedset
 ):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     assert not bbc.bed.report(record_identifier="bed1", values=test_data_bed)
     assert not bbc.bedset.report(
         record_identifier="bedset1", values=test_data_bedset
     )
Beispiel #3
0
 def test_data_insert(self, cfg_pth, test_data_bed, test_data_bedset):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     # bedfiles table
     ori_cnt = bbc.bed.record_count
     bbc.bed.report(record_identifier="bed1", values=test_data_bed)
     assert ori_cnt + 1 == bbc.bed.record_count
     # bedsets table
     ori_cnt = bbc.bedset.record_count
     bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
     assert ori_cnt + 1 == bbc.bedset.record_count
Beispiel #4
0
 def test_removal(self, cfg_pth):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     bedset_id = bbc.bedset.retrieve(
         record_identifier="bedset1", result_identifier="id"
     )
     bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
     bbc.remove_relationship(bedset_id=bedset_id, bedfile_ids=[bed_id])
     ori_cnt = bbc.bed.record_count
     bbc.bed.remove(record_identifier="bed1")
     assert ori_cnt - 1 == bbc.bed.record_count
     ori_cnt = bbc.bedset.record_count
     bbc.bedset.remove(record_identifier="bedset1")
     assert ori_cnt - 1 == bbc.bedset.record_count
Beispiel #5
0
    "-y", "--sample-yaml", dest="sample_yaml", type=str, required=False,
    help="a yaml config file with sample attributes to pass on more metadata "
         "into the database")
exclusive_group = parser.add_mutually_exclusive_group()
exclusive_group.add_argument(
    '--no-db-commit', action='store_true',
    help='whether the JSON commit to the database should be skipped')
exclusive_group.add_argument(
    '--just-db-commit', action='store_true',
    help='whether just to commit the JSON to the database')
parser = pypiper.add_pypiper_args(parser,
                                  groups=["pypiper", "common", "looper", "ngs"])

args = parser.parse_args()

bbc = bbconf.BedBaseConf(filepath=bbconf.get_bedbase_cfg(args.bedbase_config))

bed_digest = md5(open(args.bedfile, 'rb').read()).hexdigest()
bedfile_name = os.path.split(args.bedfile)[1]
# need to split twice since there are 2 exts
fileid = os.path.splitext(os.path.splitext(bedfile_name)[0])[0]
outfolder = os.path.abspath(os.path.join(
    bbc[CFG_PATH_KEY][CFG_BEDSTAT_OUTPUT_KEY], bed_digest))
json_file_path = os.path.abspath(os.path.join(outfolder, fileid + ".json"))

if not args.just_db_commit:
    pm = pypiper.PipelineManager(name="bedstat-pipeline", outfolder=outfolder,
                                 args=args)
    rscript_path = os.path.join(os.path.dirname(
        os.path.dirname(os.path.abspath(__file__))), "tools", "regionstat.R")
    assert os.path.exists(rscript_path), \
Beispiel #6
0
 def test_cant_remove_record_if_in_reltable(self, cfg_pth):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     with pytest.raises(IntegrityError):
         bbc.bed.remove(record_identifier="bed1")
     with pytest.raises(IntegrityError):
         bbc.bedset.remove(record_identifier="bedset1")
Beispiel #7
0
 def test_tables_creation(self, cfg_pth):
     bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
     for table in ["bed", "bedset"]:
         assert isinstance(getattr(bbc, table), PipestatManager)
Beispiel #8
0
 def test_invalid_config(self, invalid_cfg_pth):
     with pytest.raises(MissingConfigDataError):
         BedBaseConf(get_bedbase_cfg(cfg=invalid_cfg_pth))