diff --git a/sites/README.md b/sites/README.md index 6ec356c..0e6fd88 100644 --- a/sites/README.md +++ b/sites/README.md @@ -2,7 +2,7 @@ Use the template in this folder to add additional STR sites to the TREDPARSE run. By default, in addition to the 30 standard STR loci, TREDPARSE also look -for JSON files in `sites`` in the current working directory. +for JSON files in ``sites`` in the current working directory. Most of the details can be manually filled out, however, the ``prefix`` and ``suffix`` fields need to be computed from the reference FASTA. Therefore we've diff --git a/tredparse/meta.py b/tredparse/meta.py index 845f1a5..d6eb599 100644 --- a/tredparse/meta.py +++ b/tredparse/meta.py @@ -28,7 +28,7 @@ class TREDsRepo(dict): - def __init__(self, ref=REF, toy=False, use_sites=True): + def __init__(self, ref=REF, toy=False, sites=SITES): # Parse ALTS first alts = self.get_alts(ref) @@ -41,13 +41,12 @@ def __init__(self, ref=REF, toy=False, use_sites=True): self.df = df # Get all user loci names by searching within sites folder - if use_sites: - for sites in glob("{}/*.json".format(SITES)): - sites = byteify(json.load(open(sites))) - for name, row in sites.items(): - name = str(name) # json.loads gets a unicode - self[name] = TRED(name, row, ref=ref, alt=alts.get(name, [])) - self.names.append(name) + for s in glob("{}/*.json".format(sites)): + s = byteify(json.load(open(s))) + for name, row in s.items(): + name = str(name) # json.loads gets a unicode + self[name] = TRED(name, row, ref=ref, alt=alts.get(name, [])) + self.names.append(name) if toy: tr = self.get("HD") diff --git a/tredparse/tred.py b/tredparse/tred.py index 5674dd7..be1bcb8 100755 --- a/tredparse/tred.py +++ b/tredparse/tred.py @@ -472,10 +472,11 @@ def main(args): logger.debug("Total samples: {}".format(len(samples))) task_args = [] + sites = op.join(os.getcwd(), "sites") os.chdir(workdir) ref = args.ref - repo = TREDsRepo(ref=ref, toy=args.toy) + repo = TREDsRepo(ref=ref, toy=args.toy, sites=sites) repo.set_ploidy(args.haploid) TRED_NAMES = repo.names treds = args.tred or TRED_NAMES