diff --git a/biobb_dna/dna/dna_averages.py b/biobb_dna/dna/dna_averages.py index 6d01409d..8218d949 100755 --- a/biobb_dna/dna/dna_averages.py +++ b/biobb_dna/dna/dna_averages.py @@ -158,11 +158,11 @@ def launch(self) -> int: for i in self.seqpos] # rename duplicated subunits - while any(ser_data.columns.duplicated()): + while any(pd.Index(ser_data.columns).duplicated()): ser_data.columns = [ name if not duplicated else name + "_dup" for duplicated, name - in zip(ser_data.columns.duplicated(), ser_data.columns)] + in zip(pd.Index(ser_data.columns).duplicated(), ser_data.columns)] # write output files for all selected bases means = ser_data.mean(axis=0).iloc[:len(xlabels)] diff --git a/biobb_dna/dna/dna_bimodality.py b/biobb_dna/dna/dna_bimodality.py index 34dc5f27..c48f1983 100755 --- a/biobb_dna/dna/dna_bimodality.py +++ b/biobb_dna/dna/dna_bimodality.py @@ -10,8 +10,7 @@ import pandas as pd import numpy as np import matplotlib.pyplot as plt -from sklearn.mixture import GaussianMixture - +from sklearn.mixture import GaussianMixture # type: ignore from biobb_dna.utils import constants from biobb_common.generic.biobb_object import BiobbObject from biobb_common.configuration import settings @@ -210,12 +209,12 @@ def launch(self) -> int: label1 = "Single State" out = plt.hist( synth1, bins=bins, alpha=alpha, density=True, label=label1) - ylim = max(out[0]) + ylim = max(out[0]) # type: ignore plt.vlines(info['mean1'], 0, ylim, colors="r", linestyles="dashed") if binormal: out = plt.hist( synth2, bins=bins, alpha=alpha, density=True, label="high state") - ylim = max(out[0]) + ylim = max(out[0]) # type: ignore plt.vlines(info['mean2'], 0, ylim, colors="r", linestyles="dashed") plt.legend() plt.ylabel("Density") @@ -255,10 +254,10 @@ def fit_to_model(self, data): max_iter=self.max_iter, tol=self.tol) gmm = gmm.fit(data) - m = gmm.means_.flatten() - v = gmm.covariances_.flatten() + m = gmm.means_.flatten() # type: ignore + v = gmm.covariances_.flatten() # type: ignore b = gmm.bic(data) - w = gmm.weights_.flatten() + w = gmm.weights_.flatten() # type: ignore means.append(m) variances.append(v) bics.append(b) diff --git a/biobb_dna/dna/dna_timeseries.py b/biobb_dna/dna/dna_timeseries.py index aeee5a18..6c0d7644 100755 --- a/biobb_dna/dna/dna_timeseries.py +++ b/biobb_dna/dna/dna_timeseries.py @@ -175,9 +175,9 @@ def launch(self) -> int: # get removed items removed_items = [s for s in subunits if not pattern.fullmatch(s)] # get indices of removed items (in integer format and starting from 0) - removed_numbers = [re.match(r'\d+', item).group() for item in removed_items] + removed_numbers = [int(match.group()) for item in removed_items if (match := re.match(r'\d+', item))] removed_numbers = list(map(int, removed_numbers)) - removed_numbers = [i-1 for i in removed_numbers] + removed_numbers = [int(i)-1 for i in removed_numbers] # remove non basepairs from subunits and indices subunits = [s for s in subunits if pattern.fullmatch(s)] indices = [i for i in indices if i not in removed_numbers] diff --git a/biobb_dna/interbp_correlations/interbpcorr.py b/biobb_dna/interbp_correlations/interbpcorr.py index 4fd17cee..39a38dc0 100755 --- a/biobb_dna/interbp_correlations/interbpcorr.py +++ b/biobb_dna/interbp_correlations/interbpcorr.py @@ -185,12 +185,12 @@ def launch(self) -> int: ): method = self.circlineal else: - method = "pearson" + method = "pearson" # type: ignore corr_data = ser1.corrwith(ser2_shifted, method=method) corr_data.index = corr_index results[f"{ser1.name}/{ser2.name}"] = corr_data result_df = pd.DataFrame.from_dict(results) - result_df.index = corr_index + result_df.index = corr_index # type: ignore # save csv data result_df.to_csv(self.stage_io_dict["out"]["output_csv_path"]) @@ -199,7 +199,7 @@ def launch(self) -> int: cmap = plt.get_cmap("bwr").copy() bounds = [-1, -.8, -.6, -.4, -.2, .2, .4, .6, .8, 1] num = cmap.N - norm = mpl.colors.BoundaryNorm(bounds, num) + norm = mpl.colors.BoundaryNorm(bounds, num) # type: ignore cmap.set_bad(color="gainsboro") fig, ax = plt.subplots( 1, @@ -217,7 +217,7 @@ def launch(self) -> int: ylocs = np.arange(len(result_df.index)) _ = ax.set_yticks(ylocs) - _ = ax.set_yticklabels(result_df.index.to_list()) + _ = ax.set_yticklabels(result_df.index.to_list()) # type: ignore ax.set_title( "Correlation for neighboring basepairs " diff --git a/biobb_dna/interbp_correlations/interhpcorr.py b/biobb_dna/interbp_correlations/interhpcorr.py index 1e75371c..b839f239 100755 --- a/biobb_dna/interbp_correlations/interhpcorr.py +++ b/biobb_dna/interbp_correlations/interhpcorr.py @@ -130,11 +130,11 @@ def launch(self) -> int: # corr_matrix["shift"]["rise"] = shift.corrwith(rise, method="pearson") corr_matrix.loc["rise", "shift"] = shift.corrwith(rise, method="pearson").values[0] # corr_matrix["shift"]["tilt"] = shift.corrwith(tilt, method=self.circlineal) - corr_matrix.loc["tilt", "shift"] = shift.corrwith(tilt, method=self.circlineal).values[0] + corr_matrix.loc["tilt", "shift"] = shift.corrwith(tilt, method=self.circlineal).values[0] # type: ignore # corr_matrix["shift"]["roll"] = shift.corrwith(roll, method=self.circlineal) - corr_matrix.loc["roll", "shift"] = shift.corrwith(roll, method=self.circlineal).values[0] + corr_matrix.loc["roll", "shift"] = shift.corrwith(roll, method=self.circlineal).values[0] # type: ignore # corr_matrix["shift"]["twist"] = shift.corrwith(twist, method=self.circlineal) - corr_matrix.loc["twist", "shift"] = shift.corrwith(twist, method=self.circlineal).values[0] + corr_matrix.loc["twist", "shift"] = shift.corrwith(twist, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["slide"]["shift"] = corr_matrix["shift"]["slide"] corr_matrix.loc["shift", "slide"] = corr_matrix.loc["slide", "shift"] @@ -151,11 +151,11 @@ def launch(self) -> int: # corr_matrix["slide"]["rise"] = slide.corrwith(rise, method="pearson") corr_matrix.loc["rise", "slide"] = slide.corrwith(rise, method="pearson").values[0] # corr_matrix["slide"]["tilt"] = slide.corrwith(tilt, method=self.circlineal) - corr_matrix.loc["tilt", "slide"] = slide.corrwith(tilt, method=self.circlineal).values[0] + corr_matrix.loc["tilt", "slide"] = slide.corrwith(tilt, method=self.circlineal).values[0] # type: ignore # corr_matrix["slide"]["roll"] = slide.corrwith(roll, method=self.circlineal) - corr_matrix.loc["roll", "slide"] = slide.corrwith(roll, method=self.circlineal).values[0] + corr_matrix.loc["roll", "slide"] = slide.corrwith(roll, method=self.circlineal).values[0] # type: ignore # corr_matrix["slide"]["twist"] = slide.corrwith(twist, method=self.circlineal) - corr_matrix.loc["twist", "slide"] = slide.corrwith(twist, method=self.circlineal).values[0] + corr_matrix.loc["twist", "slide"] = slide.corrwith(twist, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["rise"]["slide"] = corr_matrix["slide"]["rise"] corr_matrix.loc["slide", "rise"] = corr_matrix.loc["rise", "slide"] @@ -168,11 +168,11 @@ def launch(self) -> int: # rise # corr_matrix["rise"]["tilt"] = rise.corrwith(tilt, method=self.circlineal) - corr_matrix.loc["tilt", "rise"] = rise.corrwith(tilt, method=self.circlineal).values[0] + corr_matrix.loc["tilt", "rise"] = rise.corrwith(tilt, method=self.circlineal).values[0] # type: ignore # corr_matrix["rise"]["roll"] = rise.corrwith(roll, method=self.circlineal) - corr_matrix.loc["roll", "rise"] = rise.corrwith(roll, method=self.circlineal).values[0] + corr_matrix.loc["roll", "rise"] = rise.corrwith(roll, method=self.circlineal).values[0] # type: ignore # corr_matrix["rise"]["twist"] = rise.corrwith(twist, method=self.circlineal) - corr_matrix.loc["twist", "rise"] = rise.corrwith(twist, method=self.circlineal).values[0] + corr_matrix.loc["twist", "rise"] = rise.corrwith(twist, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["tilt"]["rise"] = corr_matrix["rise"]["tilt"] corr_matrix.loc["rise", "tilt"] = corr_matrix.loc["tilt", "rise"] @@ -183,9 +183,9 @@ def launch(self) -> int: # tilt # corr_matrix["tilt"]["roll"] = tilt.corrwith(roll, method=self.circular) - corr_matrix.loc["roll", "tilt"] = tilt.corrwith(roll, method=self.circular).values[0] + corr_matrix.loc["roll", "tilt"] = tilt.corrwith(roll, method=self.circular).values[0] # type: ignore # corr_matrix["tilt"]["twist"] = tilt.corrwith(twist, method=self.circular) - corr_matrix.loc["twist", "tilt"] = tilt.corrwith(twist, method=self.circular).values[0] + corr_matrix.loc["twist", "tilt"] = tilt.corrwith(twist, method=self.circular).values[0] # type: ignore # symmetric values # corr_matrix["roll"]["tilt"] = corr_matrix["tilt"]["roll"] corr_matrix.loc["tilt", "roll"] = corr_matrix.loc["roll", "tilt"] @@ -194,7 +194,7 @@ def launch(self) -> int: # roll # corr_matrix["roll"]["twist"] = roll.corrwith(twist, method=self.circular) - corr_matrix.loc["twist", "roll"] = roll.corrwith(twist, method=self.circular).values[0] + corr_matrix.loc["twist", "roll"] = roll.corrwith(twist, method=self.circular).values[0] # type: ignore # symmetric values # corr_matrix["twist"]["roll"] = corr_matrix["roll"]["twist"] corr_matrix.loc["roll", "twist"] = corr_matrix.loc["twist", "roll"] diff --git a/biobb_dna/intrabp_correlations/intrabpcorr.py b/biobb_dna/intrabp_correlations/intrabpcorr.py index 6f6bfff8..dcb0a35a 100755 --- a/biobb_dna/intrabp_correlations/intrabpcorr.py +++ b/biobb_dna/intrabp_correlations/intrabpcorr.py @@ -185,12 +185,12 @@ def launch(self) -> int: ): method = self.circlineal else: - method = "pearson" + method = "pearson" # type: ignore corr_data = ser1.corrwith(ser2_shifted, method=method) corr_data.index = corr_index results[f"{ser1.name}/{ser2.name}"] = corr_data result_df = pd.DataFrame.from_dict(results) - result_df.index = corr_index + result_df.index = corr_index # type: ignore # save csv data result_df.to_csv(self.stage_io_dict["out"]["output_csv_path"]) @@ -199,7 +199,7 @@ def launch(self) -> int: cmap = plt.get_cmap("bwr").copy() bounds = [-1, -.8, -.6, -.4, -.2, .2, .4, .6, .8, 1] num = cmap.N - norm = mpl.colors.BoundaryNorm(bounds, num) + norm = mpl.colors.BoundaryNorm(bounds, num) # type: ignore cmap.set_bad(color="gainsboro") fig, ax = plt.subplots( 1, @@ -217,7 +217,7 @@ def launch(self) -> int: ylocs = np.arange(len(result_df.index)) _ = ax.set_yticks(ylocs) - _ = ax.set_yticklabels(result_df.index.to_list()) + _ = ax.set_yticklabels(result_df.index.to_list()) # type: ignore ax.set_title( "Correlation for neighboring basepairs " diff --git a/biobb_dna/intrabp_correlations/intrahpcorr.py b/biobb_dna/intrabp_correlations/intrahpcorr.py index 31ff4412..66ca044a 100755 --- a/biobb_dna/intrabp_correlations/intrahpcorr.py +++ b/biobb_dna/intrabp_correlations/intrahpcorr.py @@ -132,11 +132,11 @@ def launch(self) -> int: # corr_matrix["shear"]["stagger"] = shear.corrwith(stagger, method="pearson") corr_matrix.loc["stagger", "shear"] = shear.corrwith(stagger, method="pearson").values[0] # corr_matrix["shear"]["buckle"] = shear.corrwith(buckle, method=self.circlineal) - corr_matrix.loc["buckle", "shear"] = shear.corrwith(buckle, method=self.circlineal).values[0] + corr_matrix.loc["buckle", "shear"] = shear.corrwith(buckle, method=self.circlineal).values[0] # type: ignore # corr_matrix["shear"]["propel"] = shear.corrwith(propel, method=self.circlineal) - corr_matrix.loc["propel", "shear"] = shear.corrwith(propel, method=self.circlineal).values[0] + corr_matrix.loc["propel", "shear"] = shear.corrwith(propel, method=self.circlineal).values[0] # type: ignore # corr_matrix["shear"]["opening"] = shear.corrwith(opening, method=self.circlineal) - corr_matrix.loc["opening", "shear"] = shear.corrwith(opening, method=self.circlineal).values[0] + corr_matrix.loc["opening", "shear"] = shear.corrwith(opening, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["stretch"]["shear"] = corr_matrix["shear"]["stretch"] corr_matrix.loc["shear", "stretch"] = corr_matrix.loc["stretch", "shear"] @@ -153,11 +153,11 @@ def launch(self) -> int: # corr_matrix["stretch"]["stagger"] = stretch.corrwith(stagger, method="pearson") corr_matrix.loc["stagger", "stretch"] = stretch.corrwith(stagger, method="pearson").values[0] # corr_matrix["stretch"]["buckle"] = stretch.corrwith(buckle, method=self.circlineal) - corr_matrix.loc["buckle", "stretch"] = stretch.corrwith(buckle, method=self.circlineal).values[0] + corr_matrix.loc["buckle", "stretch"] = stretch.corrwith(buckle, method=self.circlineal).values[0] # type: ignore # corr_matrix["stretch"]["propel"] = stretch.corrwith(propel, method=self.circlineal) - corr_matrix.loc["propel", "stretch"] = stretch.corrwith(propel, method=self.circlineal).values[0] + corr_matrix.loc["propel", "stretch"] = stretch.corrwith(propel, method=self.circlineal).values[0] # type: ignore # corr_matrix["stretch"]["opening"] = stretch.corrwith(opening, method=self.circlineal) - corr_matrix.loc["opening", "stretch"] = stretch.corrwith(opening, method=self.circlineal).values[0] + corr_matrix.loc["opening", "stretch"] = stretch.corrwith(opening, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["stagger"]["stretch"] = corr_matrix["stretch"]["stagger"] corr_matrix.loc["stretch", "stagger"] = corr_matrix.loc["stagger", "stretch"] @@ -170,11 +170,11 @@ def launch(self) -> int: # stagger # corr_matrix["stagger"]["buckle"] = stagger.corrwith(buckle, method=self.circlineal) - corr_matrix.loc["buckle", "stagger"] = stagger.corrwith(buckle, method=self.circlineal).values[0] + corr_matrix.loc["buckle", "stagger"] = stagger.corrwith(buckle, method=self.circlineal).values[0] # type: ignore # corr_matrix["stagger"]["propel"] = stagger.corrwith(propel, method=self.circlineal) - corr_matrix.loc["propel", "stagger"] = stagger.corrwith(propel, method=self.circlineal).values[0] + corr_matrix.loc["propel", "stagger"] = stagger.corrwith(propel, method=self.circlineal).values[0] # type: ignore # corr_matrix["stagger"]["opening"] = stagger.corrwith(opening, method=self.circlineal) - corr_matrix.loc["opening", "stagger"] = stagger.corrwith(opening, method=self.circlineal).values[0] + corr_matrix.loc["opening", "stagger"] = stagger.corrwith(opening, method=self.circlineal).values[0] # type: ignore # symmetric values # corr_matrix["buckle"]["stagger"] = corr_matrix["stagger"]["buckle"] corr_matrix.loc["stagger", "buckle"] = corr_matrix.loc["buckle", "stagger"] @@ -185,9 +185,9 @@ def launch(self) -> int: # buckle # corr_matrix["buckle"]["propel"] = buckle.corrwith(propel, method=self.circular) - corr_matrix.loc["propel", "buckle"] = buckle.corrwith(propel, method=self.circular).values[0] + corr_matrix.loc["propel", "buckle"] = buckle.corrwith(propel, method=self.circular).values[0] # type: ignore # corr_matrix["buckle"]["opening"] = buckle.corrwith(opening, method=self.circular) - corr_matrix.loc["opening", "buckle"] = buckle.corrwith(opening, method=self.circular).values[0] + corr_matrix.loc["opening", "buckle"] = buckle.corrwith(opening, method=self.circular).values[0] # type: ignore # symmetric values # corr_matrix["propel"]["buckle"] = corr_matrix["buckle"]["propel"] corr_matrix.loc["buckle", "propel"] = corr_matrix.loc["propel", "buckle"] @@ -196,7 +196,7 @@ def launch(self) -> int: # propel # corr_matrix["propel"]["opening"] = propel.corrwith(opening, method=self.circular) - corr_matrix.loc["opening", "propel"] = propel.corrwith(opening, method=self.circular).values[0] + corr_matrix.loc["opening", "propel"] = propel.corrwith(opening, method=self.circular).values[0] # type: ignore # symmetric values # corr_matrix["opening"]["propel"] = corr_matrix["propel"]["opening"] corr_matrix.loc["propel", "opening"] = corr_matrix.loc["opening", "propel"] diff --git a/biobb_dna/utils/loader.py b/biobb_dna/utils/loader.py index 5b34fc52..76709a77 100644 --- a/biobb_dna/utils/loader.py +++ b/biobb_dna/utils/loader.py @@ -13,7 +13,7 @@ def read_series(input_serfile, usecols=None): header=None, sep='\\s+', index_col=0) - ser_data = pd.read_csv(input_serfile, **extra_kwargs) + ser_data = pd.read_csv(input_serfile, **extra_kwargs) # type: ignore if usecols is not None: if 0 in usecols: usecols.pop(usecols.index(0))