coverage.py v7.6.5, - created at 2024-11-15 12:10 +0000 + created at 2024-11-15 12:15 +0000
From aa72aab9d2a892a4d6baf5b2308cadbae0af49a5 Mon Sep 17 00:00:00 2001
From: PauAndrio
coverage.py v7.6.5,
- created at 2024-11-15 12:10 +0000
+ created at 2024-11-15 12:15 +0000
coverage.py v7.6.5,
- created at 2024-11-15 12:10 +0000
+ created at 2024-11-15 12:15 +0000
122 if self.seqpos:
123 if (max(self.seqpos) > len(self.sequence) - 2) or (min(self.seqpos) < 1):
124 raise ValueError(
-125 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
+125 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
126 )
127 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
128 raise ValueError("seqpos must be a list of at least two integers")
@@ -270,13 +270,13 @@188 def get_xlabels(self, strand1, strand2):
189 # get list of tetramers, except first and last two bases
190 labelsW = list(strand1)
-191 labelsW[0] = f"{labelsW[0]}5'"
-192 labelsW[-1] = f"{labelsW[-1]}3'"
-193 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
+191 labelsW[0] = f"{labelsW[0]}5'"
+192 labelsW[-1] = f"{labelsW[-1]}3'"
+193 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
194 labelsC = list(strand2)[::-1]
-195 labelsC[0] = f"{labelsC[0]}5'"
-196 labelsC[-1] = f"{labelsC[-1]}3'"
-197 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
+195 labelsC[0] = f"{labelsC[0]}5'"
+196 labelsC[-1] = f"{labelsC[-1]}3'"
+197 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
199 if self.seqpos is not None:
200 labelsC = [labelsC[i] for i in self.seqpos]
@@ -386,7 +386,7 @@122 if self.seqpos:
123 if (max(self.seqpos) > len(self.sequence) - 2) or (min(self.seqpos) < 1):
124 raise ValueError(
-125 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
+125 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
126 )
127 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
128 raise ValueError("seqpos must be a list of at least two integers")
@@ -278,13 +278,13 @@196 def get_xlabels(self, strand1, strand2):
197 # get list of tetramers, except first and last two bases
198 labelsW = list(strand1)
-199 labelsW[0] = f"{labelsW[0]}5'"
-200 labelsW[-1] = f"{labelsW[-1]}3'"
-201 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
+199 labelsW[0] = f"{labelsW[0]}5'"
+200 labelsW[-1] = f"{labelsW[-1]}3'"
+201 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
202 labelsC = list(strand2)[::-1]
-203 labelsC[0] = f"{labelsC[0]}5'"
-204 labelsC[-1] = f"{labelsC[-1]}3'"
-205 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
+203 labelsC[0] = f"{labelsC[0]}5'"
+204 labelsC[-1] = f"{labelsC[-1]}3'"
+205 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
207 if self.seqpos:
208 labelsC = [labelsC[i] for i in self.seqpos]
@@ -401,7 +401,7 @@114 if self.seqpos:
115 if (max(self.seqpos) > len(self.sequence) - 2) or (min(self.seqpos) < 1):
116 raise ValueError(
-117 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
+117 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
118 )
119 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
120 raise ValueError("seqpos must be a list of at least two integers")
@@ -263,13 +263,13 @@181 def get_xlabels(self, strand1, strand2):
182 # get list of tetramers, except first and last two bases
183 labelsW = list(strand1)
-184 labelsW[0] = f"{labelsW[0]}5'"
-185 labelsW[-1] = f"{labelsW[-1]}3'"
-186 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
+184 labelsW[0] = f"{labelsW[0]}5'"
+185 labelsW[-1] = f"{labelsW[-1]}3'"
+186 labelsW = [f"{i}-{j}" for i, j in zip(labelsW, range(1, len(labelsW) + 1))]
187 labelsC = list(strand2)[::-1]
-188 labelsC[0] = f"{labelsC[0]}5'"
-189 labelsC[-1] = f"{labelsC[-1]}3'"
-190 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
+188 labelsC[0] = f"{labelsC[0]}5'"
+189 labelsC[-1] = f"{labelsC[-1]}3'"
+190 labelsC = [f"{i}-{j}" for i, j in zip(labelsC, range(len(labelsC), 0, -1))]
192 if self.seqpos:
193 labelsC = [labelsC[i] for i in self.seqpos]
@@ -370,7 +370,7 @@127 if self.helpar_name not in constants.helical_parameters:
128 raise ValueError(
129 "Helical parameter name is invalid! "
-130 f"Options: {constants.helical_parameters}"
+130 f"Options: {constants.helical_parameters}"
131 )
133 # get base length and unit from helical parameter name
@@ -226,7 +226,7 @@144 if self.seqpos:
145 if (max(self.seqpos) > len(self.sequence) - 2) or (min(self.seqpos) < 1):
146 raise ValueError(
-147 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
+147 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
148 )
149 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
150 raise ValueError("seqpos must be a list of at least two integers")
@@ -242,12 +242,12 @@160 # discard first and last base(pairs) from sequence
161 sequence = self.sequence[1:]
162 xlabels = [
-163 f"{sequence[i:i+1+self.baselen]}"
+163 f"{sequence[i:i+1+self.baselen]}"
164 for i in range(len(ser_data.columns) - self.baselen)
165 ]
166 else:
167 sequence = self.sequence
-168 xlabels = [f"{sequence[i:i+1+self.baselen]}" for i in self.seqpos]
+168 xlabels = [f"{sequence[i:i+1+self.baselen]}" for i in self.seqpos]
170 # rename duplicated subunits
171 while any(pd.Index(ser_data.columns).duplicated()):
@@ -269,19 +269,19 @@187 )
188 axs.set_xticks(means.index)
189 axs.set_xticklabels(xlabels, rotation=90)
-190 axs.set_xlabel("Sequence Base Pair " f"{'Step' if self.baselen==1 else ''}")
-191 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
+190 axs.set_xlabel("Sequence Base Pair " f"{'Step' if self.baselen==1 else ''}")
+191 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
192 axs.set_title(
193 "Base Pair "
-194 f"{'Step' if self.baselen==1 else ''} "
-195 f"Helical Parameter: {self.helpar_name.capitalize()}"
+194 f"{'Step' if self.baselen==1 else ''} "
+195 f"Helical Parameter: {self.helpar_name.capitalize()}"
196 )
197 fig.savefig(self.stage_io_dict["out"]["output_jpg_path"], format="jpg")
199 # save table
200 dataset = pd.DataFrame(
201 {
-202 f"Base Pair {'Step' if self.baselen==1 else ''}": xlabels,
+202 f"Base Pair {'Step' if self.baselen==1 else ''}": xlabels,
203 "mean": means.to_numpy(),
204 "std": stds.to_numpy(),
205 }
@@ -369,7 +369,7 @@126 if self.helpar_name not in constants.helical_parameters:
127 raise ValueError(
128 "Helical parameter name is invalid! "
-129 f"Options: {constants.helical_parameters}")
+129 f"Options: {constants.helical_parameters}")
131 # get unit from helical parameter name
132 if self.helpar_name in constants.hp_angular:
@@ -300,8 +300,8 @@218 plt.vlines(info['mean2'], 0, ylim, colors="r", linestyles="dashed")
219 plt.legend()
220 plt.ylabel("Density")
-221 plt.xlabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
-222 plt.title(f"Distribution of {self.helpar_name} states")
+221 plt.xlabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
+222 plt.title(f"Distribution of {self.helpar_name} states")
223 plt.savefig(output_jpg_path, format="jpg")
224 plt.close()
@@ -426,7 +426,7 @@103 if self.helpar_name not in constants.helical_parameters:
104 raise ValueError(
105 "Helical parameter name is invalid! "
-106 f"Options: {constants.helical_parameters}"
+106 f"Options: {constants.helical_parameters}"
107 )
109 # get base length from helical parameter name
@@ -229,7 +229,7 @@147 if self.seqpos and self.helpar_name in constants.hp_basepairs:
148 if (max(cols) > len(self.sequence) - 2) or (min(cols) < 0):
149 raise ValueError(
-150 f"seqpos values must be between 1 and {len(self.sequence) - 1}"
+150 f"seqpos values must be between 1 and {len(self.sequence) - 1}"
151 )
152 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
153 raise ValueError("seqpos must be a list of at least two integers")
@@ -237,7 +237,7 @@155 elif self.seqpos and self.helpar_name not in constants.hp_basepairs:
156 if (max(cols) > len(self.sequence) - 1) or (min(cols) < 0):
157 raise ValueError(
-158 f"seqpos values must be between 1 and {len(self.sequence)}"
+158 f"seqpos values must be between 1 and {len(self.sequence)}"
159 )
160 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
161 raise ValueError("seqpos must be a list of at least two integers")
@@ -254,7 +254,7 @@172 # create indices list
173 indices = cols.copy()
174 # create subunits list from cols
-175 subunits = [f"{i+1}_{sequence[i-1:i+self.baselen]}" for i in cols]
+175 subunits = [f"{i+1}_{sequence[i-1:i+self.baselen]}" for i in cols]
176 # clean subunits (leave only basepairs)
177 pattern = re.compile(r"\d+_[A-Za-z]{2}")
178 # get removed items
@@ -277,7 +277,7 @@195 # trick for getting the index column from the .ser file
196 indices.insert(0, 0)
197 # create subunits list from cols
-198 subunits = [f"{i+1}_{sequence[i:i+1+self.baselen]}" for i in cols]
+198 subunits = [f"{i+1}_{sequence[i:i+1+self.baselen]}" for i in cols]
200 # read input .ser file
201 ser_data = read_series(
@@ -293,64 +293,64 @@211 # unstack columns to prevent errors from repeated base pairs
212 column_data = ser_data[[col]].unstack().dropna().reset_index(drop=True)
213 column_data.name = col
-214 fu.log(f"Computing base number {col}...")
+214 fu.log(f"Computing base number {col}...")
216 # column series
-217 series_colfn = f"series_{self.helpar_name}_{col}"
+217 series_colfn = f"series_{self.helpar_name}_{col}"
218 column_data.to_csv(
-219 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv"
+219 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv"
220 )
221 # save table
222 zf.write(
-223 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv",
-224 arcname=f"{series_colfn}.csv",
+223 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv",
+224 arcname=f"{series_colfn}.csv",
225 )
227 fig, axs = plt.subplots(1, 1, dpi=300, tight_layout=True)
228 reduced_data = column_data.iloc[:: self.stride]
229 axs.plot(reduced_data.index, reduced_data.to_numpy())
230 axs.set_xlabel("Time (Snapshots)")
-231 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
+231 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
232 axs.set_title(
-233 f"Helical Parameter vs Time: {self.helpar_name.capitalize()} "
+233 f"Helical Parameter vs Time: {self.helpar_name.capitalize()} "
234 "(base pair "
-235 f"{'step' if self.baselen==1 else ''} {col})"
+235 f"{'step' if self.baselen==1 else ''} {col})"
236 )
237 fig.savefig(
-238 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg",
+238 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg",
239 format="jpg",
240 )
241 # save plot
242 zf.write(
-243 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg",
-244 arcname=f"{series_colfn}.jpg",
+243 Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg",
+244 arcname=f"{series_colfn}.jpg",
245 )
246 plt.close()
248 # columns histogram
-249 hist_colfn = f"hist_{self.helpar_name}_{col}"
+249 hist_colfn = f"hist_{self.helpar_name}_{col}"
250 fig, axs = plt.subplots(1, 1, dpi=300, tight_layout=True)
251 ybins, x, _ = axs.hist(column_data, bins=self.bins)
252 pd.DataFrame({self.helpar_name: x[:-1], "density": ybins}).to_csv(
-253 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv",
+253 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv",
254 index=False,
255 )
256 # save table
257 zf.write(
-258 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv",
-259 arcname=f"{hist_colfn}.csv",
+258 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv",
+259 arcname=f"{hist_colfn}.csv",
260 )
262 axs.set_ylabel("Density")
-263 axs.set_xlabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
+263 axs.set_xlabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
264 fig.savefig(
-265 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg",
+265 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg",
266 format="jpg",
267 )
268 # save plot
269 zf.write(
-270 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg",
-271 arcname=f"{hist_colfn}.jpg",
+270 Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg",
+271 arcname=f"{hist_colfn}.jpg",
272 )
273 plt.close()
274 zf.close()
@@ -424,7 +424,7 @@106 # Check that the type is valid
107 if self.type not in ["series", "hist"]:
-108 fu.log(f"Type {self.type} not valid. Valid types are: series, hist.",
+108 fu.log(f"Type {self.type} not valid. Valid types are: series, hist.",
109 self.out_log, self.global_log)
110 exit(1)
112 # Check that the parameter is valid
113 if self.parameter not in constants.helical_parameters:
-114 fu.log(f"Parameter {self.parameter} not valid. Valid parameters are: {constants.helical_parameters}.",
+114 fu.log(f"Parameter {self.parameter} not valid. Valid parameters are: {constants.helical_parameters}.",
115 self.out_log, self.global_log)
116 exit(1)
118 # Check that the sequence is valid
119 pattern = r'^[ACGT]+$'
120 if not re.match(pattern, self.sequence):
-121 fu.log(f"Sequence {self.sequence} not valid. Only 'A', 'C', 'G' or 'T' bases allowed.",
+121 fu.log(f"Sequence {self.sequence} not valid. Only 'A', 'C', 'G' or 'T' bases allowed.",
122 self.out_log, self.global_log)
123 exit(1)
125 # Check that the index is valid
126 if self.index < 1 or self.index >= len(self.sequence) - 1:
-127 fu.log(f"Index {self.index} not valid. It should be between 0 and {len(self.sequence) - 2}.",
+127 fu.log(f"Index {self.index} not valid. It should be between 0 and {len(self.sequence) - 2}.",
128 self.out_log, self.global_log)
129 exit(1)
@@ -214,39 +214,39 @@132 bp = self.sequence[self.index-1] + self.sequence[self.index]
134 # Get the filename
-135 filename = f"{self.type}_{self.parameter}_{self.index}_{bp}"
-136 csv_file = f"{filename}.csv"
-137 jpg_file = f"{filename}.jpg"
+135 filename = f"{self.type}_{self.parameter}_{self.index}_{bp}"
+136 csv_file = f"{filename}.csv"
+137 jpg_file = f"{filename}.jpg"
139 # Unzip the file
140 with zipfile.ZipFile(self.stage_io_dict["in"]["input_zip_file"], 'r') as zip_ref:
141 # Check if the csv file exists in the zip file
142 if csv_file in zip_ref.namelist():
143 # Extract the file
-144 fu.log(f'{csv_file} exists, copying into {self.stage_io_dict["out"]["output_path_csv"]}.',
+144 fu.log(f'{csv_file} exists, copying into {self.stage_io_dict["out"]["output_path_csv"]}.',
145 self.out_log, self.global_log)
146 with zip_ref.open(csv_file) as source, open(self.stage_io_dict["out"]["output_path_csv"], "wb") as target:
147 shutil.copyfileobj(source, target)
148 else:
-149 fu.log(f"File {csv_file} not found in the zip file.", self.out_log, self.global_log)
+149 fu.log(f"File {csv_file} not found in the zip file.", self.out_log, self.global_log)
150 exit(1)
152 # Check if the jpg file exists in the zip file
153 if jpg_file in zip_ref.namelist():
154 # Extract the file
-155 fu.log(f'{jpg_file} exists, copying into {self.stage_io_dict["out"]["output_path_jpg"]}.',
+155 fu.log(f'{jpg_file} exists, copying into {self.stage_io_dict["out"]["output_path_jpg"]}.',
156 self.out_log, self.global_log)
157 with zip_ref.open(jpg_file) as source, open(self.stage_io_dict["out"]["output_path_jpg"], "wb") as target:
158 shutil.copyfileobj(source, target)
159 else:
-160 fu.log(f"File {jpg_file} not found in the zip file.", self.out_log, self.global_log)
+160 fu.log(f"File {jpg_file} not found in the zip file.", self.out_log, self.global_log)
161 exit(1)
163 # Write the list of files
164 if self.stage_io_dict["out"]["output_list_path"]:
165 with open(self.stage_io_dict["out"]["output_list_path"], "w") as f:
166 for name in zip_ref.namelist():
-167 f.write(f"{name}\n")
+167 f.write(f"{name}\n")
169 # Run Biobb block
170 # self.run_biobb()
@@ -322,7 +322,7 @@160 propel = propel[propel.columns[1:-1]]
161 opening = opening[opening.columns[1:-1]]
162 labels = [
-163 f"{i+1}_{self.sequence[i:i+1]}"
+163 f"{i+1}_{self.sequence[i:i+1]}"
164 for i in range(1, len(shear.columns) + 1)
165 ]
166 corr_index = [
-167 f"{self.sequence[i:i+2]}" for i in range(1, len(shear.columns) + 1)
+167 f"{self.sequence[i:i+2]}" for i in range(1, len(shear.columns) + 1)
168 ]
169 else:
-170 labels = [f"{i+1}_{self.sequence[i:i+1]}" for i in self.seqpos]
-171 corr_index = [f"{self.sequence[i:i+2]}" for i in self.seqpos]
+170 labels = [f"{i+1}_{self.sequence[i:i+1]}" for i in self.seqpos]
+171 corr_index = [f"{self.sequence[i:i+2]}" for i in self.seqpos]
173 # rename duplicated subunits
174 shear.columns = labels
@@ -288,7 +288,7 @@206 method = "pearson" # type: ignore
207 corr_data = ser1.corrwith(ser2_shifted, method=method)
208 corr_data.index = corr_index
-209 results[f"{ser1.name}/{ser2.name}"] = corr_data
+209 results[f"{ser1.name}/{ser2.name}"] = corr_data
210 result_df = pd.DataFrame.from_dict(results)
211 result_df.index = corr_index # type: ignore
@@ -464,7 +464,7 @@213 axs.text(
214 j+.5,
215 i+.5,
-216 f"{corr_matrix[coordinates[j]].loc[coordinates[i]]:.2f}",
+216 f"{corr_matrix[coordinates[j]].loc[coordinates[i]]:.2f}",
217 ha="center",
218 va="center",
219 color="w")
@@ -305,7 +305,7 @@223 axs.set_yticklabels(corr_matrix.index)
224 axs.set_title(
225 "Helical Parameter Correlation "
-226 f"for Base Pair Step \'{self.base}\'")
+226 f"for Base Pair Step \'{self.base}\'")
227 fig.tight_layout()
228 fig.savefig(
229 self.stage_io_dict['out']['output_jpg_path'],
@@ -432,7 +432,7 @@119 if self.helpar_name not in constants.helical_parameters:
120 raise ValueError(
121 "Helical parameter name is invalid! "
-122 f"Options: {constants.helical_parameters}"
+122 f"Options: {constants.helical_parameters}"
123 )
125 # get base length and unit from helical parameter name
@@ -225,9 +225,9 @@143 ser_data = ser_data[ser_data.columns[1:-1]]
144 # discard first and last base(pairs) from strands
145 sequence = self.sequence[1:]
-146 labels = [f"{i+1}_{sequence[i:i+1]}" for i in range(len(ser_data.columns))]
+146 labels = [f"{i+1}_{sequence[i:i+1]}" for i in range(len(ser_data.columns))]
147 else:
-148 labels = [f"{i+1}_{self.sequence[i:i+1]}" for i in self.seqpos]
+148 labels = [f"{i+1}_{self.sequence[i:i+1]}" for i in self.seqpos]
149 ser_data.columns = labels
151 # make matrix
@@ -245,7 +245,7 @@163 axs.text(
164 j + 0.5,
165 i + 0.5,
-166 f"{corr_data[corr_data.columns[j]].iloc[i]:.2f}",
+166 f"{corr_data[corr_data.columns[j]].iloc[i]:.2f}",
167 ha="center",
168 va="center",
169 color="w",
@@ -255,7 +255,7 @@173 axs.set_yticks([i + 0.5 for i in range(len(corr_data))])
174 axs.set_yticklabels(labels)
175 axs.set_title(
-176 "Base Pair Correlation " f"for Helical Parameter '{self.helpar_name}'"
+176 "Base Pair Correlation " f"for Helical Parameter '{self.helpar_name}'"
177 )
178 fig.tight_layout()
179 fig.savefig(self.stage_io_dict["out"]["output_jpg_path"], format="jpg")
@@ -350,7 +350,7 @@123 if line.strip().startswith("Strand 1"):
124 self.sequence = line.split(" ")[-1]
125 fu.log(
-126 f"using sequence {self.sequence} "
-127 f"from {self.stage_io_dict['in']['input_lis_file']}",
+126 f"using sequence {self.sequence} "
+127 f"from {self.stage_io_dict['in']['input_lis_file']}",
128 self.out_log)
130 # define temporary file name
@@ -218,29 +218,29 @@137 # create intructions
138 instructions = [
-139 f"{self.binary_path} <<! ",
+139 f"{self.binary_path} <<! ",
140 "&inp",
141 " lis=canal_output,"]
142 if self.bases is not None:
143 # add topology file if needed
144 fu.log('Appending sequence of bases to be searched to command',
145 self.out_log, self.global_log)
-146 instructions.append(f" seq={self.bases},")
+146 instructions.append(f" seq={self.bases},")
147 if self.nastr is not None:
148 # add topology file if needed
149 fu.log('Adding null values string specification to command',
150 self.out_log, self.global_log)
-151 instructions.append(f" nastr={self.nastr},")
+151 instructions.append(f" nastr={self.nastr},")
153 instructions = instructions + [
-154 f" cormin={self.cormin},",
-155 f" lev1={self.lev1},lev2={self.lev2},",
-156 f" itst={self.itst},itnd={self.itnd},itdel={self.itdel},",
-157 f" histo={self.histo},",
-158 f" series={self.series},",
-159 f" corr={self.corr},",
+154 f" cormin={self.cormin},",
+155 f" lev1={self.lev1},lev2={self.lev2},",
+156 f" itst={self.itst},itnd={self.itnd},itdel={self.itdel},",
+157 f" histo={self.histo},",
+158 f" series={self.series},",
+159 f" corr={self.corr},",
160 "&end",
-161 f"{tmp_cda_path} {self.sequence}",
+161 f"{tmp_cda_path} {self.sequence}",
162 "!"]
164 self.cmd = ["\n".join(instructions)]
@@ -329,7 +329,7 @@135 ]
136 if self.type not in ion_type_options:
137 raise ValueError(("Invalid value for property type! "
-138 f"Option include: {ion_type_options}"))
+138 f"Option include: {ion_type_options}"))
140 # define temporary file names
141 input_cdi_file = Path(self.stage_io_dict['in']['input_cdi_path']).name
@@ -230,29 +230,29 @@149 # create intructions
150 instructions = [
-151 f"{self.binary_path} <<! ",
+151 f"{self.binary_path} <<! ",
152 "&inp",
153 " lis=canion_output,",
-154 f" dat={input_cdi_file[:-4]},",
-155 f" axfrm={input_afr_file[:-4]},",
-156 f" solute={input_avg_struc[:-4]},",
-157 f" type={self.type},",
-158 f" dlow={self.dlow},",
-159 f" dhig={self.dhig},",
-160 f" rlow={self.rlow},",
-161 f" rhig={self.rhig},",
-162 f" alow={self.alow},",
-163 f" ahig={self.ahig},",
-164 f" itst={self.itst},",
-165 f" itnd={self.itnd},",
-166 f" itdel={self.itdel},",
-167 f" rmsf={self.rmsf},",
-168 f" circ={self.circ},"]
+154 f" dat={input_cdi_file[:-4]},",
+155 f" axfrm={input_afr_file[:-4]},",
+156 f" solute={input_avg_struc[:-4]},",
+157 f" type={self.type},",
+158 f" dlow={self.dlow},",
+159 f" dhig={self.dhig},",
+160 f" rlow={self.rlow},",
+161 f" rhig={self.rhig},",
+162 f" alow={self.alow},",
+163 f" ahig={self.ahig},",
+164 f" itst={self.itst},",
+165 f" itnd={self.itnd},",
+166 f" itdel={self.itdel},",
+167 f" rmsf={self.rmsf},",
+168 f" circ={self.circ},"]
169 if self.bases is not None:
170 # add topology file if needed
171 fu.log('Appending sequence of bases to be searched to command',
172 self.out_log, self.global_log)
-173 instructions.append(f" seq={self.bases},")
+173 instructions.append(f" seq={self.bases},")
174 instructions.append("&end")
175 instructions.append("!")
176 self.cmd = ["\n".join(instructions)]
@@ -341,7 +341,7 @@134 range1_end = int(self.s1range.split(":")[1])
135 s2start = range1_end + 1
136 s2end = 2 * range1_end
-137 self.s2range = f"{s2end}:{s2start}"
+137 self.s2range = f"{s2end}:{s2start}"
139 # check standard library files location if not provided
140 if self.stdlib_path is None:
@@ -228,14 +228,14 @@146 if len(list(curves_aux_path.glob("standard_*.lib"))) != 3:
147 raise FileNotFoundError(
148 "One or all standard library files "
-149 f"missing from {curves_aux_path}! "
+149 f"missing from {curves_aux_path}! "
150 "Check files standard_b.lib, "
151 "standard_s.lib and standard_i.lib exist.")
152 self.stdlib_path = curves_aux_path / "standard"
153 else:
154 raise FileNotFoundError(
155 ".curvesplus directory not found in "
-156 f"{os.getenv('CONDA_PREFIX')} !"
+156 f"{os.getenv('CONDA_PREFIX')} !"
157 "Please indicate where standard_*.lib files are "
158 "located with the stdlib_path property.")
159 # copy standard library files to temporary folder
@@ -267,30 +267,30 @@186 # create intructions
187 instructions = [
-188 f"{self.binary_path} <<! ",
+188 f"{self.binary_path} <<! ",
189 "&inp",
-190 f" file={tmp_struc_input},"]
+190 f" file={tmp_struc_input},"]
191 if self.stage_io_dict['in']['input_top_path'] is not None:
192 # add topology file if needed
193 fu.log('Appending provided topology to command',
194 self.out_log, self.global_log)
195 instructions.append(
-196 f" ftop={tmp_top_input},")
+196 f" ftop={tmp_top_input},")
198 # create intructions
199 instructions = instructions + [
200 " lis='curves_output',",
-201 f" lib={relative_lib_path},",
-202 f" ions={self.ions},",
-203 f" test={self.test},",
-204 f" line={self.line},",
-205 f" fit={self.fit},",
-206 f" axfrm={self.axfrm},",
-207 f" itst={self.itst},itnd={self.itnd},itdel={self.itdel},",
+201 f" lib={relative_lib_path},",
+202 f" ions={self.ions},",
+203 f" test={self.test},",
+204 f" line={self.line},",
+205 f" fit={self.fit},",
+206 f" axfrm={self.axfrm},",
+207 f" itst={self.itst},itnd={self.itnd},itdel={self.itdel},",
208 "&end",
209 "2 1 -1 0 0",
-210 f"{self.s1range}",
-211 f"{self.s2range}",
+210 f"{self.s1range}",
+211 f"{self.s2range}",
212 "!"
213 ]
214 self.cmd = ["\n".join(instructions)]
@@ -393,7 +393,7 @@115 }
116 # Check that the type is valid
117 if self.type not in extensions:
-118 fu.log(f"Type {self.type} not valid. Valid types are: {', '.join(extensions.keys())}.",
+118 fu.log(f"Type {self.type} not valid. Valid types are: {', '.join(extensions.keys())}.",
119 self.out_log, self.global_log)
120 exit(1)
@@ -207,7 +207,7 @@125 # Check that the correlation is valid
126 pattern = r'\d+_\d+'
127 if not re.match(pattern, self.correlation):
-128 fu.log(f"Correlation {self.correlation} not valid. It should match the pattern <number_number>.",
+128 fu.log(f"Correlation {self.correlation} not valid. It should match the pattern <number_number>.",
129 self.out_log, self.global_log)
130 exit(1)
131 sufix = self.correlation
@@ -219,32 +219,32 @@137 "opening", "phaseC", "phaseW", "propel", "reg", "rise", "roll", "shear",
138 "shift", "slide", "stagger", "stretch", "tbend", "tilt", "tip", "twist",
139 "xdisp", "ydisp", "zetaC", "zetaW"]:
-140 fu.log(f"Parameter {self.helpar_name} not valid. Valid parameters are: alphaC, alphaW, ampC, ampW, ax-bend, betaC, betaW, buckle, chiC, chiW, curv, deltaC, deltaW, epsilC, epsilW, gammaC, gammaW, h-ris, h-twi, inclin, majd, majw, mind, minw, opening, phaseC, phaseW, propel, reg, rise, roll, shear, shift, slide, stagger, stretch, tbend, tilt, tip, twist, xdisp, ydisp, zetaC, zetaW.",
+140 fu.log(f"Parameter {self.helpar_name} not valid. Valid parameters are: alphaC, alphaW, ampC, ampW, ax-bend, betaC, betaW, buckle, chiC, chiW, curv, deltaC, deltaW, epsilC, epsilW, gammaC, gammaW, h-ris, h-twi, inclin, majd, majw, mind, minw, opening, phaseC, phaseW, propel, reg, rise, roll, shear, shift, slide, stagger, stretch, tbend, tilt, tip, twist, xdisp, ydisp, zetaC, zetaW.",
141 self.out_log, self.global_log)
142 exit(1)
143 sufix = self.helpar_name
145 # Generate the filename
-146 filename = f"canal_output_{sufix}.{extensions[self.type]}"
+146 filename = f"canal_output_{sufix}.{extensions[self.type]}"
148 # Unzip the file
149 with zipfile.ZipFile(self.stage_io_dict["in"]["input_zip_file"], 'r') as zip_ref:
150 # Check if the file exists in the zip file
151 if filename in zip_ref.namelist():
152 # Extract the file
-153 fu.log(f'{filename} exists, copying into {self.stage_io_dict["out"]["output_path"]}.',
+153 fu.log(f'{filename} exists, copying into {self.stage_io_dict["out"]["output_path"]}.',
154 self.out_log, self.global_log)
155 with zip_ref.open(filename) as source, open(self.stage_io_dict["out"]["output_path"], "wb") as target:
156 shutil.copyfileobj(source, target)
157 else:
-158 fu.log(f"File {filename} not found in the zip file.", self.out_log, self.global_log)
+158 fu.log(f"File {filename} not found in the zip file.", self.out_log, self.global_log)
159 exit(1)
161 # Write the list of files
162 if self.stage_io_dict["out"]["output_list_path"]:
163 with open(self.stage_io_dict["out"]["output_list_path"], "w") as f:
164 for name in zip_ref.namelist():
-165 f.write(f"{name}\n")
+165 f.write(f"{name}\n")
167 # Run Biobb block
168 # self.run_biobb()
@@ -315,7 +315,7 @@160 roll = roll[roll.columns[1:-2]]
161 twist = twist[twist.columns[1:-2]]
162 labels = [
-163 f"{i+1}_{self.sequence[i:i+2]}"
+163 f"{i+1}_{self.sequence[i:i+2]}"
164 for i in range(1, len(shift.columns) + 1)
165 ]
166 corr_index = [
-167 f"{self.sequence[i:i+3]}" for i in range(1, len(shift.columns) + 1)
+167 f"{self.sequence[i:i+3]}" for i in range(1, len(shift.columns) + 1)
168 ]
169 else:
-170 labels = [f"{i+1}_{self.sequence[i:i+2]}" for i in self.seqpos]
-171 corr_index = [f"{self.sequence[i:i+3]}" for i in self.seqpos]
+170 labels = [f"{i+1}_{self.sequence[i:i+2]}" for i in self.seqpos]
+171 corr_index = [f"{self.sequence[i:i+3]}" for i in self.seqpos]
173 # rename duplicated subunits
174 shift.columns = labels
@@ -288,7 +288,7 @@206 method = "pearson" # type: ignore
207 corr_data = ser1.corrwith(ser2_shifted, method=method)
208 corr_data.index = corr_index
-209 results[f"{ser1.name}/{ser2.name}"] = corr_data
+209 results[f"{ser1.name}/{ser2.name}"] = corr_data
210 result_df = pd.DataFrame.from_dict(results)
211 result_df.index = corr_index # type: ignore
@@ -468,7 +468,7 @@211 axs.text(
212 j+.5,
213 i+.5,
-214 f"{corr_matrix[coordinates[j]].loc[coordinates[i]]:.2f}",
+214 f"{corr_matrix[coordinates[j]].loc[coordinates[i]]:.2f}",
215 ha="center",
216 va="center",
217 color="w")
@@ -303,7 +303,7 @@221 axs.set_yticklabels(corr_matrix.index)
222 axs.set_title(
223 "Helical Parameter Correlation "
-224 f"for Base Pair Step \'{self.basepair}\'")
+224 f"for Base Pair Step \'{self.basepair}\'")
225 fig.tight_layout()
226 fig.savefig(
227 self.stage_io_dict['out']['output_jpg_path'],
@@ -430,7 +430,7 @@123 if self.helpar_name not in constants.helical_parameters:
124 raise ValueError(
125 "Helical parameter name is invalid! "
-126 f"Options: {constants.helical_parameters}"
+126 f"Options: {constants.helical_parameters}"
127 )
129 # get base length and unit from helical parameter name
@@ -229,9 +229,9 @@147 ser_data = ser_data[ser_data.columns[1:-1]]
148 # discard first and last base(pairs) from strands
149 sequence = self.sequence[1:]
-150 labels = [f"{i+1}_{sequence[i:i+2]}" for i in range(len(ser_data.columns))]
+150 labels = [f"{i+1}_{sequence[i:i+2]}" for i in range(len(ser_data.columns))]
151 else:
-152 labels = [f"{i+1}_{self.sequence[i:i+2]}" for i in self.seqpos]
+152 labels = [f"{i+1}_{self.sequence[i:i+2]}" for i in self.seqpos]
153 ser_data.columns = labels
155 # make matrix
@@ -249,7 +249,7 @@167 axs.text(
168 j + 0.5,
169 i + 0.5,
-170 f"{corr_data[corr_data.columns[j]].iloc[i]:.2f}",
+170 f"{corr_data[corr_data.columns[j]].iloc[i]:.2f}",
171 ha="center",
172 va="center",
173 color="w",
@@ -259,7 +259,7 @@177 axs.set_yticks([i + 0.5 for i in range(len(corr_data))])
178 axs.set_yticklabels(labels)
179 axs.set_title(
-180 "Base Pair Correlation " f"for Helical Parameter '{self.helpar_name}'"
+180 "Base Pair Correlation " f"for Helical Parameter '{self.helpar_name}'"
181 )
182 fig.tight_layout()
183 fig.savefig(self.stage_io_dict["out"]["output_jpg_path"], format="jpg")
@@ -354,7 +354,7 @@127 if self.helpar_name not in constants.helical_parameters:
128 raise ValueError(
129 "Helical parameter name is invalid! "
-130 f"Options: {constants.helical_parameters}"
+130 f"Options: {constants.helical_parameters}"
131 )
133 # get base length and unit from helical parameter name
@@ -224,7 +224,7 @@142 if self.seqpos:
143 if (max(self.seqpos) > len(self.sequence) - 2) or (min(self.seqpos) < 1):
144 raise ValueError(
-145 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
+145 f"seqpos values must be between 1 and {len(self.sequence) - 2}"
146 )
147 if not (isinstance(self.seqpos, list) and len(self.seqpos) > 1):
148 raise ValueError("seqpos must be a list of at least two integers")
@@ -239,10 +239,10 @@157 ser_data = ser_data[ser_data.columns[1:-1]]
158 # discard first and last base(pairs) from sequence
159 sequence = self.sequence[1:]
-160 xlabels = [f"{sequence[i:i+2]}" for i in range(len(ser_data.columns))]
+160 xlabels = [f"{sequence[i:i+2]}" for i in range(len(ser_data.columns))]
161 else:
162 sequence = self.sequence
-163 xlabels = [f"{sequence[i:i+2]}" for i in self.seqpos]
+163 xlabels = [f"{sequence[i:i+2]}" for i in self.seqpos]
165 # calculate average stiffness
166 cov = ser_data.cov()
@@ -255,15 +255,15 @@173 axs.set_xticks(range(len(xlabels)))
174 axs.set_xticklabels(xlabels)
175 axs.set_xlabel("Sequence Base Pair")
-176 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
+176 axs.set_ylabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})")
177 axs.set_title(
-178 "Base Pair Helical Parameter Stiffness: " f"{self.helpar_name.capitalize()}"
+178 "Base Pair Helical Parameter Stiffness: " f"{self.helpar_name.capitalize()}"
179 )
180 fig.savefig(self.stage_io_dict["out"]["output_jpg_path"], format="jpg")
182 # save table
183 dataset = pd.DataFrame(
-184 data=avg_stiffness, index=xlabels, columns=[f"{self.helpar_name}_stiffness"]
+184 data=avg_stiffness, index=xlabels, columns=[f"{self.helpar_name}_stiffness"]
185 )
186 dataset.to_csv(self.stage_io_dict["out"]["output_csv_path"])
@@ -348,7 +348,7 @@158 axs.text(
159 j + 0.5,
160 i + 0.5,
-161 f"{stiff_df[coordinates[j]].loc[coordinates[i]]:.2f}",
+161 f"{stiff_df[coordinates[j]].loc[coordinates[i]]:.2f}",
162 ha="center",
163 va="center",
164 color="w",
@@ -257,7 +257,7 @@175 axs.set_xticklabels(stiff_df.columns, rotation=90)
176 axs.set_yticks([i + 0.5 for i in range(len(stiff_df))])
177 axs.set_yticklabels(stiff_df.index)
-178 axs.set_title(f"Stiffness Constants for Base Pair Step '{basepairname}'")
+178 axs.set_title(f"Stiffness Constants for Base Pair Step '{basepairname}'")
179 fig.tight_layout()
180 fig.savefig(self.stage_io_dict["out"]["output_jpg_path"], format="jpg")
181 plt.close()
@@ -381,7 +381,7 @@+ + +
++ + +
+Generated on 2024-11-15 12:09 +
Generated on 2024-11-15 12:14 with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
Report generated on 15-Nov-2024 at 12:10:13 by pytest-html +
Report generated on 15-Nov-2024 at 12:15:43 by pytest-html v4.1.1
19 tests took 00:00:25.
+19 tests took 00:00:27.
(Un)check the boxes to filter the results.