Skip to content

Commit b6419a1

Browse files
committed
PEP-8 formatting NO_JIRA
1 parent a6a6666 commit b6419a1

File tree

7 files changed

+40
-38
lines changed

7 files changed

+40
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
A repository containing scripts that have been created to leverage the toolkit found within
77
the [CCDC portfolio](https://www.ccdc.cam.ac.uk/solutions/) that are accessible via
8-
the [CSD Python API ](https://www.ccdc.cam.ac.uk/solutions/csd-core/components/csd-python-api/).
8+
the [CSD Python API](https://www.ccdc.cam.ac.uk/solutions/csd-core/components/csd-python-api/).
99

1010
The purpose of this platform is to distribute knowledge and allow for scientific collaborations. Scripts are provided on an as-is basis and while their use is not supported we do welcome feedback on potential improvements. All scripts are tested against the latest version of the CSD Python API as installed with the CSD Portfolio.
1111

scripts/concat_mol2/concat_mol2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def main(delete_separate_files):
4242
help='Remove contributing individual mol2 files after concatenation')
4343

4444
args = parser.parse_args()
45-
main(args.delete_contributors)
45+
main(args.delete_contributors)

scripts/create_castep_input/create_castep_input.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ def make_castep_input(crystal, kp_spacing=0.06, cut_off=750.000, task='SinglePoi
7878
param_file.write('write_cell_structure : true\n')
7979
param_file.write('#continuation : default\n')
8080

81-
8281
return True
83-
82+
83+
8484
if __name__ == '__main__':
8585
helper = ApplicationInterface()
8686
entry = helper.current_entry
8787
crystal = entry.crystal
8888
os.chdir(helper.output_directory_path)
8989
make_castep_input(crystal)
90-

scripts/create_gaussian_input/create_gaussian_input.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import sys
2020
import os
2121
import ccdc.io
22-
import glob
2322

2423

2524
def fatal(*args):
@@ -82,4 +81,4 @@ def file_writer(molecule, name):
8281
mol = reader.molecule(entry_id)
8382
file_writer(mol, identifier)
8483
except RuntimeError:
85-
fatal(entry_id, '- structure not found')
84+
fatal(entry_id, '- structure not found')

scripts/hydrogen_bond_propensity/hydrogen_bond_propensity_report.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
hydrogen_bond_propensity_report.py
1515
- Writes a .docx report of a hydrogen bond propensity calculation
1616
"""
17+
18+
import argparse
19+
import os
20+
import sys
21+
import subprocess
22+
import csv
1723
import matplotlib
24+
1825
matplotlib.use('Agg')
1926
import matplotlib.pyplot as plt
2027

@@ -23,14 +30,9 @@
2330
from ccdc.search import SubstructureSearch, ConnserSubstructure
2431
from ccdc.descriptors import CrystalDescriptors
2532

26-
import argparse
27-
import os
28-
import sys
29-
import subprocess
30-
import csv
31-
3233
try:
3334
import warnings
35+
3436
with warnings.catch_warnings():
3537
warnings.simplefilter("ignore", category=DeprecationWarning)
3638
import docxtpl
@@ -81,7 +83,7 @@ def fg_diagram(mol, directory, con):
8183
def add_picture_subdoc(picture_location, docx_template, cm=7):
8284
# This function adds a picture to the .docx file
8385
return docxtpl.InlineImage(
84-
docx_template, image_descriptor=picture_location, width=Cm(cm))
86+
docx_template, image_descriptor=picture_location, width=Cm(cm))
8587

8688

8789
def launch_word_processor(output_file):
@@ -137,7 +139,7 @@ def propensity_calc(crystal, directory):
137139
observed_group = hbp.target_hbond_grouping()
138140

139141
return hbp.functional_groups, hbp.fitting_data, hbp.donors, hbp.acceptors, model, \
140-
propensities, intra_flag, groups, observed_group
142+
propensities, intra_flag, groups, observed_group
141143

142144

143145
def coordination_scores_calc(crystal, directory):
@@ -214,8 +216,8 @@ def main(structure, directory, csdrefcode, noopen=False):
214216
work_directory = os.path.join(directory, str(structure).split('.')[0])
215217

216218
# Get all the necessary data from a HBP calculation
217-
functional_groups, fitting_data, donors, acceptors, model, propensities, intra_flag,\
218-
groups, observed_groups = propensity_calc(crystal, work_directory)
219+
functional_groups, fitting_data, donors, acceptors, model, propensities, intra_flag, \
220+
groups, observed_groups = propensity_calc(crystal, work_directory)
219221

220222
# Calculate the coordination scores separately
221223
coordination_scores = coordination_scores_calc(crystal, work_directory)
@@ -322,8 +324,8 @@ def main(structure, directory, csdrefcode, noopen=False):
322324
if __name__ == '__main__':
323325
# Set up the necessary arguments to run the script
324326
parser = argparse.ArgumentParser(
325-
formatter_class=argparse.RawDescriptionHelpFormatter,
326-
description=__doc__)
327+
formatter_class=argparse.RawDescriptionHelpFormatter,
328+
description=__doc__)
327329
parser.add_argument('input_structure', type=str,
328330
help='Refcode or mol2 file of the component to be screened')
329331
parser.add_argument('-d', '--directory', default=os.getcwd(),

scripts/multi_component_hydrogen_bond_propensity/multi_component_hydrogen_bond_propensity_report.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@
1414
- Performs a multi-component HBP calculation for a given library of co-formers
1515
"""
1616

17+
import sys
18+
import os
19+
import glob
20+
import argparse
21+
import tempfile
22+
import subprocess
23+
1724
import matplotlib
25+
1826
matplotlib.use('TkAgg')
1927
import matplotlib.pyplot as plt
2028

2129
from ccdc import io, molecule
2230
from ccdc.diagram import DiagramGenerator
2331
from ccdc.descriptors import CrystalDescriptors
2432

25-
import sys
26-
import os
27-
import glob
28-
import argparse
29-
import tempfile
30-
import subprocess
31-
3233
try:
3334
import warnings
35+
3436
with warnings.catch_warnings():
3537
warnings.simplefilter("ignore", category=DeprecationWarning)
3638
import docxtpl
@@ -54,9 +56,9 @@
5456
def cm2inch(*tupl):
5557
inch = 2.54
5658
if isinstance(tupl[0], tuple):
57-
return tuple(i/inch for i in tupl[0])
59+
return tuple(i / inch for i in tupl[0])
5860
else:
59-
return tuple(i/inch for i in tupl)
61+
return tuple(i / inch for i in tupl)
6062

6163

6264
def launch_word_processor(output_file):
@@ -113,7 +115,7 @@ def make_mc_chart(dictionary, directory, mol):
113115
def add_picture_subdoc(picture_location, docx_template, wd=7):
114116
# This function adds a picture to the .docx file
115117
return docxtpl.InlineImage(
116-
docx_template, image_descriptor=picture_location, width=Cm(wd))
118+
docx_template, image_descriptor=picture_location, width=Cm(wd))
117119

118120

119121
def propensity_calc(crystal, directory):
@@ -147,7 +149,7 @@ def propensity_calc(crystal, directory):
147149
# Perform regression
148150
model = hbp.perform_regression()
149151
print(model.equation)
150-
print('Area under ROC curve: {} -- {}'.format(round(model.area_under_roc_curve, 3), model.advice_comment))
152+
print('Area under ROC curve: {} -- {}'.format(round(model.area_under_roc_curve, 3), model.advice_comment))
151153
hbp.calculate_propensities()
152154
propensities = hbp.inter_propensities
153155

@@ -293,7 +295,7 @@ def make_mc_report(identifier, results, directory, diagram_file, chart_file):
293295

294296
# Generate content for the report
295297
diagram = add_picture_subdoc(diagram_file, docx_template)
296-
chart = add_picture_subdoc(chart_file, docx_template,wd=18)
298+
chart = add_picture_subdoc(chart_file, docx_template, wd=18)
297299

298300
# The context is the information that is given to the template to allow it to be populated
299301
context = {
@@ -375,15 +377,15 @@ def main(structure, work_directory, library, csdrefcode):
375377
'ccdc_coformers'
376378
)
377379
parser = argparse.ArgumentParser(
378-
formatter_class=argparse.RawDescriptionHelpFormatter,
379-
description=__doc__)
380+
formatter_class=argparse.RawDescriptionHelpFormatter,
381+
description=__doc__)
380382
parser.add_argument('input_structure', type=str,
381-
help='Refcode or mol2 file of the component to be screened')
383+
help='Refcode or mol2 file of the component to be screened')
382384
parser.add_argument('-d', '--directory', default=os.getcwd(),
383-
help='the working directory for the calculation')
385+
help='the working directory for the calculation')
384386
parser.add_argument('-c', '--coformer_library', type=str,
385-
help='the directory of the desired coformer library',
386-
default=ccdc_coformers_dir)
387+
help='the directory of the desired coformer library',
388+
default=ccdc_coformers_dir)
387389

388390
args = parser.parse_args()
389391

scripts/packing_similarity_dendrogram/packing_similarity_dendogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import sys
1717
import argparse
18+
import os
1819
import matplotlib
1920

2021
matplotlib.use('Agg')
@@ -23,7 +24,6 @@
2324
import numpy as np
2425

2526
import matplotlib.pyplot as plt
26-
import os
2727

2828

2929
def strip_terminal(name, reader):

0 commit comments

Comments
 (0)