Skip to content

Commit

Permalink
Merge pull request #107 from rigdenlab/anode
Browse files Browse the repository at this point in the history
Set a default work dir and changed how the cleanup function was called
  • Loading branch information
hlasimpk committed Jul 15, 2019
2 parents 90a3a66 + 1078757 commit 7f0014d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions simbad/mr/anomalous_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def work_dir(self, work_dir):
"""Define the working directory"""
self._work_dir = work_dir

def run(self, input_model):
def run(self, input_model, cleanup=True):
"""Function to run SFALL/CAD/FFT to create phased anomalous fourier map"""
if not os.path.isdir(self.work_dir):
os.mkdir(self.work_dir)
Expand All @@ -85,7 +85,8 @@ def run(self, input_model):
self.mtz2sca()
self.shelxc()
self.anode(input_model)
self.cleanup()
if cleanup:
self.cleanup()
os.chdir(cwd)

def search_results(self):
Expand Down Expand Up @@ -127,7 +128,7 @@ def anode(self, input_model):
cexec(cmd)

def cleanup(self):
for i in ["{0}_fa.hkl", "{0}_fa.ins", "{0}_fa.res", "{0}.hkl", "{0}.pha", "{0}.sca"]:
for i in ["{0}_fa.hkl", "{0}_fa.ins", "{0}_fa.res", "{0}.hkl", "{0}.sca"]:
f = os.path.join(self.work_dir, i.format(self.name))
if os.path.isfile(f):
os.remove(f)
Expand All @@ -140,8 +141,10 @@ def cleanup(self):

group.add_argument("-xyzin", type=str, help="Path to the input xyz file")
group.add_argument("-hklin", type=str, help="Path to the input hkl file")
group.add_argument("-work_dir", type=str, help="Path to the working directory")
group.add_argument("-work_dir", type=str, help="Path to the working directory", default=os.getcwd())
group.add_argument('--cleanup', default=False, action="store_true", help="Delete all none essential files")

args = parser.parse_args()

anomalous_search = AnodeSearch(os.path.abspath(args.hklin), os.path.abspath(args.work_dir))
anomalous_search.run(os.path.abspath(args.xyzin))
anomalous_search.run(os.path.abspath(args.xyzin), cleanup=args.cleanup)

0 comments on commit 7f0014d

Please sign in to comment.