Skip to content

Commit

Permalink
Merge pull request #3 from MikeDacre/dev
Browse files Browse the repository at this point in the history
Basic multiprocessing now working
  • Loading branch information
MikeDacre authored May 9, 2017
2 parents e4b1bc6 + 1c37a60 commit 3466121
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions LD_Direction/compare_snp_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,12 @@ def one_to_many(self, snp, comp_list, chrom, r2=0.6, populations=None,
return None
bad = []
for s in comp_list:
if snp not in bim_snps:
if s not in bim_snps:
bad.append(s)
comp_list.remove(s)
if bad:
_sys.stderr.write(('{} removed from comparison list as not in ' +
'bim file\n').format(bad))
del(bim_snps)
# Build the command
plink_cmnd = (
Expand Down Expand Up @@ -644,7 +647,7 @@ def filter_by_ld(pairs, r2=0.6, populations=None, plink='plink'):
multi = True if l > 200 else False
if multi:
jobs = {}
if _fyrd:
if _fyrd and _fyrd.queue.MODE != 'local':
print('Running jobs on the cluster with fyrd.')
else:
pool = _mp.Pool()
Expand All @@ -657,7 +660,7 @@ def filter_by_ld(pairs, r2=0.6, populations=None, plink='plink'):
args = (snps, plink, chrom, r2, populations)
if multi:
args += (False, )
if _fyrd:
if _fyrd and _fyrd.queue.MODE != 'local':
jobs[chrom] = _fyrd.submit(
_ld_job, args, walltime="01:00:00", mem='8G', cores=4)
else:
Expand All @@ -670,7 +673,7 @@ def filter_by_ld(pairs, r2=0.6, populations=None, plink='plink'):
print('Getting results from parallel jobs')
for chrom, job in jobs.items():
results[chrom] = job.get()
if not _fyrd:
if not _fyrd and _fyrd.queue.MODE != 'local':
pool.close()

# Add all data back again
Expand Down

0 comments on commit 3466121

Please sign in to comment.