Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,16 @@ def format_scores(scores, das, d_type):
return formatted_scores


def get_mc_scores(propensities, identifier):
def get_mc_scores(propensities, identifier, ignore_intra:bool):
# Calculates the multi-component scores from the individual HBP calculation
AA_propensities = []
BB_propensities = []
AB_propensities = []
BA_propensities = []

if ignore_intra is True:
propensities = [p for p in propensities if p.is_intermolecular]

for p in propensities:
t = "%s_d" % p.donor_label.split(" ")[0], "%s_a" % p.acceptor_label.split(" ")[0]
if '_A_' in t[0] and '_A_' in t[1]:
Expand Down Expand Up @@ -323,7 +326,7 @@ def make_mc_report(identifier, results, directory, diagram_file, chart_file):
launch_word_processor(output_file)


def main(structure, work_directory, failure_directory, library, csdrefcode, force_run):
def main(structure, work_directory, failure_directory, library, csdrefcode, ignore_intra, force_run):
# This loads up the CSD if a refcode is requested, otherwise loads the structural file supplied
if csdrefcode:
try:
Expand Down Expand Up @@ -371,10 +374,9 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
propensities, donors, acceptors = hbp_calculator.calculate()
coordination_scores = coordination_scores_calc(crystal, directory)
pair_output(crystal.identifier, propensities, donors, acceptors, coordination_scores, directory)
mc_dictionary[coformer_name] = get_mc_scores(propensities, crystal.identifier, ignore_intra)
with open(os.path.join(directory, "success.json"), "w") as file:
tdata = get_mc_scores(propensities, crystal.identifier)
json.dump(tdata, file)
mc_dictionary[coformer_name] = get_mc_scores(propensities, crystal.identifier)
json.dump(mc_dictionary[coformer_name], file)
except Exception as error_message:
print("Propensity calculation failure for %s!" % coformer_name)
error_string = f"{coformer_name}: {error_message}"
Expand Down Expand Up @@ -429,7 +431,8 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
default=ccdc_coformers_dir)
parser.add_argument('-f', '--failure_directory', type=str,
help='The location where the failures file should be generated')

parser.add_argument('-i', '--ignore_intra', action='store_true', default='False',
help='Ignore intramolecular hydrogen bonds when ranking pairs')
parser.add_argument('--force_run_disordered', action="store_true",
help='Forces running the script on disordered entries. (NOT RECOMMENDED)', default=False)

Expand All @@ -447,4 +450,4 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
parser.error('%s - library not found.' % args.coformer_library)

main(args.input_structure, args.directory, args.failure_directory, args.coformer_library, refcode,
args.force_run_disordered)
args.ignore_intra, args.force_run_disordered)