Skip to content

Commit

Permalink
change PDB/PDB-Dev ID case for files
Browse files Browse the repository at this point in the history
  • Loading branch information
aozalevsky committed Jul 23, 2024
1 parent 43a3cf1 commit 86c5267
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 66 deletions.
7 changes: 4 additions & 3 deletions ihm_validation/cx.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def infinite_defaultdict(): return defaultdict(infinite_defaultdict)
class CxValidation(GetInputInformation):
def __init__(self, mmcif_file):
super().__init__(mmcif_file)
self.ID = str(self.get_id())
self.ID = self.get_id()
self.ID_f = self.get_file_id()
self.nos = self.get_number_of_models()
self.dataset = self.get_dataset_comp()
# Only atomic structures are supported so far
Expand Down Expand Up @@ -863,7 +864,7 @@ def plot_distograms_per_model_group(self, imgDirname='.'):
def save_plots(self, plot, title, imgDirname='.'):
imgpath = Path(
imgDirname,
f'{self.ID}_{title}.html')
f'{self.ID_f}_{title}.html')
save(
plot, imgpath,
resources=CDN,
Expand All @@ -872,7 +873,7 @@ def save_plots(self, plot, title, imgDirname='.'):

imgpath_json = Path(
imgDirname,
f'{self.ID}_{title}.json')
f'{self.ID_f}_{title}.json')

with open(imgpath_json, 'w') as f:
json.dump(json_item(plot, title), f)
Expand Down
5 changes: 3 additions & 2 deletions ihm_validation/excludedvolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
class GetExcludedVolume(GetInputInformation):
def __init__(self, mmcif_file, cache):
super().__init__(mmcif_file)
self.ID = Path(self.mmcif_file).stem
self.ID = self.get_id()
self.ID_f = self.get_file_id()
self.nos = self.get_number_of_models()
self.cache = cache

Expand Down Expand Up @@ -156,7 +157,7 @@ def get_exc_vol_given_sphere_parallel(self, sphere_list: list) -> (float, int):
def run_exc_vol_parallel(self, model_dict: dict) -> dict:
""" get exc vol info in parallel """
# list_of_sphere_list=list(model_dict.values())
filename = str(Path(self.cache, self.ID + '_exv.txt'))
filename = str(Path(self.cache, self.ID_f + '_exv.txt'))
if os.path.exists(filename):
return self.process_exv(filename)

Expand Down
21 changes: 11 additions & 10 deletions ihm_validation/get_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
class Plots(GetInputInformation):
def __init__(self, mmcif, imageDirName, driver):
super().__init__(mmcif)
self.ID = str(GetInputInformation.get_id(self))
self.ID = self.get_id()
self.ID_f = self.get_file_id()
self.dirname = os.path.dirname(os.path.abspath(__file__))
self.imageDirName = imageDirName
self.filename = os.path.join(self.imageDirName)
Expand All @@ -41,7 +42,7 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
sas_data: dict, sas_fit: dict, cx_fit: dict) -> bokeh.plotting.figure:

# create tabs list to add all the panel figures (model quality, data quality.. etc)
output_file(self.ID+"quality_at_glance.html", mode="inline")
output_file(self.ID_f+ "_" + "quality_at_glance.html", mode="inline")

# MODEL QUALITY
# check for molprobity or excluded volume data
Expand Down Expand Up @@ -99,7 +100,7 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
plots.append(p)

export_svg(p, filename=self.filename+'/' +
self.ID+'_' + str(i) + "_quality_at_glance_MQ.svg", webdriver=self.driver)
self.ID_f + "_" + str(i) + "_quality_at_glance_MQ.svg", webdriver=self.driver)


grid = gridplot(plots, ncols=1,
Expand Down Expand Up @@ -166,7 +167,7 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
plots.append(p)

export_svg(p, filename=self.filename+'/' +
self.ID+'_' + str(i) + "_quality_at_glance_MQ.svg", webdriver=self.driver)
self.ID_f + "_" + str(i) + "_quality_at_glance_MQ.svg", webdriver=self.driver)

grid = gridplot(plots, ncols=1,
merge_tools=True,
Expand Down Expand Up @@ -207,9 +208,9 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
# make panel figures
# first panel is model quality
export_svg(fullplot, filename=self.filename+'/' +
self.ID+"quality_at_glance_MQ.svg", webdriver=self.driver)
self.ID_f + "_" +"quality_at_glance_MQ.svg", webdriver=self.driver)
save(fullplot, filename=self.filename+'/' +
self.ID+"quality_at_glance_MQ.html")
self.ID_f + "_" +"quality_at_glance_MQ.html")

# DATA QUALITY
# check for sas data, if exists, plot
Expand Down Expand Up @@ -245,9 +246,9 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
pd.title.align = "center"
pd.output_backend = "svg"
export_svg(pd, filename=self.filename+'/' +
self.ID+"quality_at_glance_DQ.svg", webdriver=self.driver)
self.ID_f + "_" +"quality_at_glance_DQ.svg", webdriver=self.driver)
save(pd, filename=self.filename+'/' +
self.ID+"quality_at_glance_DQ.html")
self.ID_f + "_" +"quality_at_glance_DQ.html")

# FIT TO DATA QUALITY
# check for sas data, if exists, plot
Expand Down Expand Up @@ -285,6 +286,6 @@ def plot_quality_at_glance(self, molprobity_data: dict, exv_data: dict,
pf.title.align = "center"
pf.output_backend = "svg"
export_svg(pf, filename=self.filename+'/' +
self.ID+"quality_at_glance_FQ.svg", webdriver=self.driver)
self.ID_f + '_' +"quality_at_glance_FQ.svg", webdriver=self.driver)
save(pf, filename=self.filename+'/' +
self.ID+"quality_at_glance_FQ.html")
self.ID_f + '_' +"quality_at_glance_FQ.html")
29 changes: 28 additions & 1 deletion ihm_validation/mmcif_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,34 @@ def get_databases(self):

def get_id(self):
"""Return _entry.id; Requires compliant CIF file"""
entry_id = self.system.id
ids = self.get_ranked_id_list()

if len(ids) == 0:
raise(ValueError('Missing system ID'))

id_type, entry_id = ids[0]

return entry_id

def get_file_id(self):
"""Return _entry.id; Requires compliant CIF file"""
ids = self.get_ranked_id_list()

if len(ids) == 0:
raise(ValueError('Missing system ID'))

id_type, entry_id = ids[0]

if id_type == 'PDB ID':
# PDB filenames have to be lowercase
entry_id = entry_id.lower()
elif id_type == 'PDB-Dev ID':
# PDB-Dev filenames have to be uppercase
entry_id = entry_id.upper()
else:
# Use entry ID as is
pass

return entry_id

def get_pdb_id(self) -> str:
Expand Down
2 changes: 2 additions & 0 deletions ihm_validation/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def run_entry_composition(self, Template_Dict: dict) -> dict:
Template_Dict['flex'] = utility.get_flex(
utility.dict_to_JSlist_rows(RB, flex))
entry_id = self.input.get_id()
file_id = self.input.get_file_id()
Template_Dict['ID'] = entry_id
Template_Dict['ID_f'] = file_id
Template_Dict['PDB_ID'] = self.input.get_pdb_id()
Template_Dict['PDBDEV_ID'] = self.input.get_pdb_dev_id()
Template_Dict['ranked_id_list'] = self.input.get_ranked_id_list()
Expand Down
2 changes: 1 addition & 1 deletion ihm_validation/sas.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SasValidation(GetInputInformation):
def __init__(self, mmcif_file, db='.'):
super().__init__(mmcif_file)
self.version = self.get_atsas_version()
self.ID = str(GetInputInformation.get_id(self))
self.ID = self.get_id()
self.nos = GetInputInformation.get_number_of_models(self)
self.dataset = GetInputInformation.get_dataset_comp(self)
self.imagepath = '../static/images/'
Expand Down
51 changes: 26 additions & 25 deletions ihm_validation/sas_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
class SasValidationPlots(sas.SasValidation):
def __init__(self, mmcif_file, imageDirName, driver):
super().__init__(mmcif_file)
self.ID = str(GetInputInformation.get_id(self))
self.ID = self.get_id()
self.ID_f = self.get_file_id()
# self.intensities = self.get_intensities()
# self.intensities = self.modify_intensity()

Expand All @@ -39,7 +40,7 @@ def plot_intensities(self, sasbdb: str, df: pd.DataFrame):
'''
plot intensities with errors
'''
output_file(self.ID+sasbdb+"intensities.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"intensities.html", mode="inline")
source = ColumnDataSource(df)
p = figure(plot_height=350, plot_width=350,
title=f"Log I(q) vs q with error bars\n{sasbdb}",
Expand All @@ -61,16 +62,16 @@ def plot_intensities(self, sasbdb: str, df: pd.DataFrame):
p.xaxis.axis_label_text_font_style = 'italic'
p.yaxis.axis_label_text_font_style = 'italic'

save(p, filename=self.filename+'/'+self.ID+sasbdb+"intensities.html")
save(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"intensities.html")
p.output_backend = "svg"
export_svg(p, height=350, width=350, filename=self.filename +
'/'+self.ID+sasbdb+"intensities.svg", webdriver=self.driver)
'/'+self.ID_f + '_' +sasbdb+"intensities.svg", webdriver=self.driver)

def plot_intensities_log(self, sasbdb: str, df: pd.DataFrame):
'''
plot intensities on a log scale with errors
'''
output_file(self.ID+sasbdb+"intensities_log.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"intensities_log.html", mode="inline")
source = ColumnDataSource(df)
p = figure(plot_height=350, plot_width=350,
title=f"Log I(q) vs Log q with error bars\n{sasbdb}",
Expand All @@ -93,16 +94,16 @@ def plot_intensities_log(self, sasbdb: str, df: pd.DataFrame):
p.yaxis.axis_label_text_font_style = 'italic'

save(p, filename=self.filename+'/' +
self.ID+sasbdb+"intensities_log.html")
self.ID_f + '_' +sasbdb+"intensities_log.html")
p.output_backend = "svg"
export_svg(p, height=350, width=350, filename=self.filename +
'/'+self.ID+sasbdb+"intensities_log.svg", webdriver=self.driver)
'/'+self.ID_f + '_' +sasbdb+"intensities_log.svg", webdriver=self.driver)

def plot_kratky(self, sasbdb: str, df: pd.DataFrame):
'''
plot dimensionless kratky
'''
output_file(self.ID+sasbdb+"Kratky.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"Kratky.html", mode="inline")
source = ColumnDataSource(df)
p = figure(plot_height=350, plot_width=350,
title=f"Dimensionless Kratky plot\n{sasbdb}",
Expand All @@ -124,15 +125,15 @@ def plot_kratky(self, sasbdb: str, df: pd.DataFrame):
p.yaxis.axis_label_text_font_size = '14pt'
p.xaxis.axis_label_text_font_style = 'italic'
p.yaxis.axis_label_text_font_style = 'italic'
save(p, filename=self.filename+'/'+self.ID+sasbdb+"Kratky.html")
save(p, filename=self.filename+'/'+self.ID_f+ '_' + sasbdb+"Kratky.html")
p.output_backend = "svg"
export_svg(p, filename=self.filename+'/'+self.ID+sasbdb+"Kratky.svg", webdriver=self.driver)
export_svg(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"Kratky.svg", webdriver=self.driver)

def plot_porod_debye(self, sasbdb: str, df: pd.DataFrame):
'''
porod debye plot for flexibility
'''
output_file(self.ID+sasbdb+"porod.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"porod.html", mode="inline")
source = ColumnDataSource(df)
p = figure(plot_height=350, plot_width=350,
title=f"Porod-Debye plot\n{sasbdb}",
Expand All @@ -152,14 +153,14 @@ def plot_porod_debye(self, sasbdb: str, df: pd.DataFrame):
p.xaxis.axis_label_text_font_style = 'italic'
p.yaxis.axis_label_text_font_style = 'italic'
p.output_backend = "svg"
save(p, filename=self.filename+'/'+self.ID+sasbdb+"porod.html")
export_svg(p, filename=self.filename+'/'+self.ID+sasbdb+"porod.svg", webdriver=self.driver)
save(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"porod.html")
export_svg(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"porod.svg", webdriver=self.driver)

def plot_pddf(self, sasbdb: str, df: pd.DataFrame, Rg=None, Dmax=None):
'''
p(r) plot, deprecated function
'''
output_file(self.ID+sasbdb+"pddf.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"pddf.html", mode="inline")
source = ColumnDataSource(df)
ymax = max(df['P']) * 1.1

Expand Down Expand Up @@ -197,8 +198,8 @@ def plot_pddf(self, sasbdb: str, df: pd.DataFrame, Rg=None, Dmax=None):
p.output_backend = "svg"
p.xaxis.axis_label_text_font_style = 'italic'
p.yaxis.axis_label_text_font_style = 'italic'
save(p, filename=self.filename+'/'+self.ID+sasbdb+"pddf.html")
export_svg(p, height=350, width=350, filename=self.filename+'/'+self.ID+sasbdb+"pddf.svg", webdriver=self.driver)
save(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"pddf.html")
export_svg(p, height=350, width=350, filename=self.filename+'/'+self.ID_f+ "_" + sasbdb+"pddf.svg", webdriver=self.driver)

def plot_pddf_int_rwt(self, sasbdb: str,
df_int: pd.DataFrame,
Expand All @@ -207,7 +208,7 @@ def plot_pddf_int_rwt(self, sasbdb: str,
'''
p(r) with fit
'''
output_file(self.ID+sasbdb+"pddf_int.html", mode="inline")
output_file(self.ID_f + '_' + sasbdb+"pddf_int.html", mode="inline")
source1 = ColumnDataSource(df_int)
source2 = ColumnDataSource(df_pofr)
p1 = figure(plot_height=350, plot_width=350,
Expand Down Expand Up @@ -267,16 +268,16 @@ def plot_pddf_int_rwt(self, sasbdb: str,
p.width = 350
p.height = 550

save(p, filename=self.filename+'/'+self.ID+sasbdb+"pddf_int.html")
save(p, filename=self.filename+'/'+self.ID_f + '_' + sasbdb+"pddf_int.html")
# p.output_backend = "svg"
export_svg(p, filename=self.filename+'/' +
self.ID+sasbdb+"pddf_int.svg", webdriver=self.driver)
self.ID_f + '_' + sasbdb+"pddf_int.svg", webdriver=self.driver)

def Guinier_plot_fit_rwt(self, sasbdb: str, df: pd.DataFrame, score: float):
'''
Gunier plot with fit
'''
output_file(self.ID+sasbdb+"guinier.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+"guinier.html", mode="inline")
source = ColumnDataSource(df)
p1 = figure(plot_height=350, plot_width=350,
title=f"Guinier plot for {sasbdb}")
Expand Down Expand Up @@ -338,8 +339,8 @@ def Guinier_plot_fit_rwt(self, sasbdb: str, df: pd.DataFrame, score: float):
p.height = 550


save(p, filename=self.filename+'/'+self.ID+sasbdb+"guinier.html")
export_svg(p, filename=self.filename+'/'+self.ID+sasbdb+"guinier.svg", webdriver=self.driver)
save(p, filename=self.filename+'/'+self.ID_f+ '_' + sasbdb+"guinier.html")
export_svg(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+"guinier.svg", webdriver=self.driver)


def plot_multiple(self):
Expand Down Expand Up @@ -384,7 +385,7 @@ def plot_fit_rwt(self, sasbdb: str, fit: int, score: float, df: pd.DataFrame):
'''
plot chi-squared fit
'''
output_file(self.ID+sasbdb+str(fit)+"fit1.html", mode="inline")
output_file(self.ID_f + '_' +sasbdb+str(fit)+"fit1.html", mode="inline")
source = ColumnDataSource(df)
p1 = figure(plot_height=350, plot_width=350,
title=f"Model fit for {sasbdb}, model {fit + 1}")
Expand Down Expand Up @@ -440,7 +441,7 @@ def plot_fit_rwt(self, sasbdb: str, fit: int, score: float, df: pd.DataFrame):
p = gridplot([p1, p2], ncols=1,
toolbar_location="above")

save(p, filename=self.filename+'/'+self.ID+sasbdb+str(fit)+"fit1.html")
save(p, filename=self.filename+'/'+self.ID_f + '_' +sasbdb+str(fit)+"fit1.html")
# p.output_backend = "svg"
export_svg(p, filename=self.filename+'/' +
self.ID+sasbdb+str(fit)+"fit1.svg", webdriver=self.driver)
self.ID_f + '_' +sasbdb+str(fit)+"fit1.svg", webdriver=self.driver)
14 changes: 7 additions & 7 deletions templates/data_quality.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ <h5 class= ex2 align= center>
<!-- plots -->
<div class=row>
<!-- log I(q) vs q plot -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "intensities") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "intensities") }}
<!-- log I(q) vs log q plot -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "intensities_log") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "intensities_log") }}
</div>
</div>
</div>
Expand Down Expand Up @@ -112,9 +112,9 @@ <h5 class= ex2 align= center>
<!-- plots -->
<div class=row>
<!-- Porod-Debye plot -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "porod") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "porod") }}
<!-- Dimensionless Kratky plot -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "Kratky") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "Kratky") }}
</div>
{% endfor %}
</div>
Expand Down Expand Up @@ -142,9 +142,9 @@ <h5 align= center>
<!-- main plots -->
<div class=row>
<!-- Pair distance distribution function -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "pddf") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "pddf") }}
<!-- P(r) extrapolated fit -->
{{ insert_sas_plot(ID, sasdb_code_html[i], "pddf_int") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "pddf_int") }}
</div>
{% endfor %}
</div>
Expand Down Expand Up @@ -183,7 +183,7 @@ <h5 class= ex2 align= center><u><a name=firstG> Guinier analysis </a></u><a clas
<!-- Guinier plot -->
<div class=row>
{% for i in range(sasdb_code_html|length) %}
{{ insert_sas_plot(ID, sasdb_code_html[i], "guinier") }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], "guinier") }}
{% endfor %}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/formodeling.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5 class= ex2 align= center>
{% for i in range(sasdb_code_html|length) %}
{% for j in range(sasdb_code_fits[i]) %}
{% set k = j + 1 %}
{{ insert_sas_plot(ID, sasdb_code_html[i], j|int ~ 'fit1') }}
{{ insert_sas_plot(ID_f, sasdb_code_html[i], j|int ~ 'fit1') }}
{% endfor %}
{% endfor %}
</div>
Expand Down
Loading

0 comments on commit 86c5267

Please sign in to comment.