Skip to content

Commit

Permalink
Merge pull request #8 from Alexandre83/fix/packages_updates
Browse files Browse the repository at this point in the history
fix: packages updates & windows compatibility
  • Loading branch information
Joseph-Ellaway authored Oct 31, 2023
2 parents f15a10f + 60be7d6 commit 827a279
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
15 changes: 8 additions & 7 deletions DihedralCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

# Removes warning messages from Biopython. Comment out to debug
import warnings

warnings.filterwarnings("ignore")

import Bio.PDB
import pandas as pd
import numpy as np
import math

import Bio.PDB
import numpy as np
import pandas as pd


def ResidueNames(chain):
Expand Down Expand Up @@ -232,13 +233,13 @@ def ModelDihedrals(model, model_num, iter_chains=True, chain_id=None):

for chain in model:
chain_summaryDF = ChainSummary(chain)
model_summaryDF = model_summaryDF.append(chain_summaryDF, ignore_index=True)
model_summaryDF = pd.concat([model_summaryDF, chain_summaryDF], ignore_index=True)

# If multiple chains are present, default: calculate dihedrals from all chains
else:
chain = model[chain_id]
chain_summaryDF = ChainSummary(chain)
model_summaryDF = model_summaryDF.append(chain_summaryDF, ignore_index=True)
model_summaryDF = pd.concat([model_summaryDF, chain_summaryDF], ignore_index=True)

# Append model number information to final DataFrame
model_ID_list = [model_num] * len(model_summaryDF)
Expand Down Expand Up @@ -275,7 +276,7 @@ def ExtractDihedrals(pdb_file_name=None, iter_models=True, model_number=0,
for model in models:

model_dihedrals = ModelDihedrals(model, model_number, iter_chains, chain_id)
pdb_summaryDF = pdb_summaryDF.append(model_dihedrals, ignore_index=True)
pdb_summaryDF = pd.concat([pdb_summaryDF, model_dihedrals], ignore_index=True)

model_number += 1

Expand All @@ -284,7 +285,7 @@ def ExtractDihedrals(pdb_file_name=None, iter_models=True, model_number=0,
try:
model = Bio.PDB.PDBParser().get_structure(pdb_code, pdb_file_name)[model_number]
model_dihedrals = ModelDihedrals(model, model_number)
pdb_summaryDF = pdb_summaryDF.append(model_dihedrals, ignore_index=True)
pdb_summaryDF = pd.concat([pdb_summaryDF, model_dihedrals], ignore_index=True)
# Invalid model number given
except:
inv_model = True
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ The dependence previous versions of Ramachandran-Plotter had on Phenix has been

## Bug fixes:

### 07/10/2023

Crash fixes:
- Dataframe.append(...) is deprecated since pandas 2.0, replaced by pandas.concat(...)
- Matplotlib style *seaborn-poster* was renamed *seaborn-v0_8-poster* since 3.6.3 version

Bug fixes:
- Temporary png image was not deleted on Windows, replace *os.command()* by *os.remove()*

### 27/03/2022

- Improved readability:
Expand Down
11 changes: 6 additions & 5 deletions RamachandranPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@
====================================================================================
"""

import os

import matplotlib.pyplot as plt
# Base functions
import pandas as pd
import matplotlib.pyplot as plt
import os

# Package functions
from DihedralCalculator import *
from PlotterFunctions import *
from RamaArgumentParser import *


# Main function
def main(pdb, itmod, model_num, itchain, chain_num, plot_type, out_dir, verb, save, file_type):

Expand Down Expand Up @@ -117,7 +119,7 @@ def main(pdb, itmod, model_num, itchain, chain_num, plot_type, out_dir, verb, sa
# Plotting user's PDB dihedral angles
VerboseStatement(verb, "Plotting Ramachandran diagram")

plt.style.use("seaborn-poster")
plt.style.use("seaborn-v0_8-poster")

fig, ax = plt.subplots(1,1, figsize=figure_size, tight_layout=True) # Defining plot area.

Expand Down Expand Up @@ -150,8 +152,7 @@ def main(pdb, itmod, model_num, itchain, chain_num, plot_type, out_dir, verb, sa
# ... as PDF
plt.savefig(str(plot_name[:-4] + '.' + file_type), bbox_inches=0, pad_inches=None)

rm_command = str("rm " + plot_name + ".png")
os.system(rm_command)
os.remove(str(plot_name + '.png'))

plt.close()

Expand Down

0 comments on commit 827a279

Please sign in to comment.