From eff6555e9c4519946b2dd6f0e356c4057fd11a5a Mon Sep 17 00:00:00 2001 From: Pau Andrio Date: Tue, 22 Oct 2024 12:26:55 +0200 Subject: [PATCH] Update --- .gitignore | 2 ++ biobb_dna/curvesplus/biobb_canal.py | 4 ++-- biobb_dna/curvesplus/biobb_canion.py | 4 ++-- biobb_dna/curvesplus/biobb_curves.py | 16 ++++++++-------- biobb_dna/dna/dna_bimodality.py | 4 ++-- biobb_dna/dna/dna_timeseries.py | 16 ++++++++-------- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index a3a197f8..969f4a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +# Files too big to be stored in gitTHGA_K.cdi + .gitignore __pycache__/ *.py[cod] diff --git a/biobb_dna/curvesplus/biobb_canal.py b/biobb_dna/curvesplus/biobb_canal.py index e139252a..99881f34 100755 --- a/biobb_dna/curvesplus/biobb_canal.py +++ b/biobb_dna/curvesplus/biobb_canal.py @@ -132,7 +132,7 @@ def launch(self) -> int: # change directory to temporary folder original_directory = os.getcwd() - os.chdir(self.stage_io_dict.get("unique_dir")) + os.chdir(self.stage_io_dict.get("unique_dir", "")) # create intructions instructions = [ @@ -174,7 +174,7 @@ def launch(self) -> int: # create zipfile and write output inside zf = zipfile.ZipFile( Path(self.stage_io_dict["out"]["output_zip_path"]), "w") - for canal_outfile in Path(self.stage_io_dict.get("unique_dir")).glob("canal_output*"): + for canal_outfile in Path(self.stage_io_dict.get("unique_dir", "")).glob("canal_output*"): if canal_outfile.suffix not in (".zip"): zf.write( canal_outfile, diff --git a/biobb_dna/curvesplus/biobb_canion.py b/biobb_dna/curvesplus/biobb_canion.py index 90dd256a..4e7a5519 100755 --- a/biobb_dna/curvesplus/biobb_canion.py +++ b/biobb_dna/curvesplus/biobb_canion.py @@ -144,7 +144,7 @@ def launch(self) -> int: # change directory to temporary folder original_directory = os.getcwd() - os.chdir(self.stage_io_dict.get("unique_dir")) + os.chdir(self.stage_io_dict.get("unique_dir", "")) # create intructions instructions = [ @@ -187,7 +187,7 @@ def launch(self) -> int: zf = zipfile.ZipFile( Path(self.stage_io_dict["out"]["output_zip_path"]), "w") - for curves_outfile in Path(self.stage_io_dict.get("unique_dir")).glob("canion_output*"): + for curves_outfile in Path(self.stage_io_dict.get("unique_dir", "")).glob("canion_output*"): if curves_outfile.suffix not in (".zip"): zf.write(curves_outfile, arcname=curves_outfile.name) zf.close() diff --git a/biobb_dna/curvesplus/biobb_curves.py b/biobb_dna/curvesplus/biobb_curves.py index d48e609c..a2f26d8f 100755 --- a/biobb_dna/curvesplus/biobb_curves.py +++ b/biobb_dna/curvesplus/biobb_curves.py @@ -110,7 +110,7 @@ def __init__( def create_curvesplus_folder(self): """Create .curvesplus folder in the current temporal folder and copy the lib files inside.""" # Create .curvesplus directory in temporary folder - dst_dir = self.stage_io_dict.get("unique_dir") + '/.curvesplus' + dst_dir = self.stage_io_dict.get("unique_dir", "") + '/.curvesplus' os.makedirs(dst_dir, exist_ok=True) # Get lib files from stdlib_path lib_files = list(Path(os.path.dirname(self.stdlib_path)).glob("*.lib")) @@ -140,7 +140,7 @@ def launch(self) -> int: if self.stdlib_path is None: if os.getenv("CONDA_PREFIX", False): curves_aux_path = Path( - os.getenv("CONDA_PREFIX")) / ".curvesplus" + os.getenv("CONDA_PREFIX", "")) / ".curvesplus" # check if .curvesplus directory is in $CONDA_PREFIX if curves_aux_path.exists(): if len(list(curves_aux_path.glob("standard_*.lib"))) != 3: @@ -157,7 +157,7 @@ def launch(self) -> int: "Please indicate where standard_*.lib files are " "located with the stdlib_path property.") # copy standard library files to temporary folder - shutil.copytree(curves_aux_path, self.stage_io_dict.get("unique_dir") + '/.curvesplus') + shutil.copytree(curves_aux_path, self.stage_io_dict.get("unique_dir", "") + '/.curvesplus') relative_lib_path = '.curvesplus/standard' else: # CONDA_PREFIX undefined @@ -171,12 +171,12 @@ def launch(self) -> int: # create .curvesplus folder in the current temporal folder and copy the lib files inside self.create_curvesplus_folder() # set relative path - path_parts = self.stdlib_path.split(os.sep) + path_parts = str(self.stdlib_path).split(os.sep) relative_lib_path = '.curvesplus/' + os.sep.join(path_parts[-1:]) # change directory to temporary folder original_directory = os.getcwd() - os.chdir(self.stage_io_dict.get("unique_dir")) + os.chdir(self.stage_io_dict.get("unique_dir", "")) # define temporary file names tmp_struc_input = Path(self.stage_io_dict['in']['input_struc_path']).name @@ -226,7 +226,7 @@ def launch(self) -> int: zf = zipfile.ZipFile( Path(self.stage_io_dict["out"]["output_zip_path"]), "w") - for curves_outfile in Path(self.stage_io_dict.get("unique_dir")).glob("curves_output*"): + for curves_outfile in Path(self.stage_io_dict.get("unique_dir", "")).glob("curves_output*"): if curves_outfile.suffix not in (".cda", ".lis", ".zip"): zf.write( curves_outfile, @@ -234,9 +234,9 @@ def launch(self) -> int: zf.close() # rename cda and lis files - (Path(self.stage_io_dict.get("unique_dir")) / "curves_output.cda").rename( + (Path(self.stage_io_dict.get("unique_dir", "")) / "curves_output.cda").rename( self.stage_io_dict["out"]["output_cda_path"]) - (Path(self.stage_io_dict.get("unique_dir")) / "curves_output.lis").rename( + (Path(self.stage_io_dict.get("unique_dir", "")) / "curves_output.lis").rename( self.stage_io_dict["out"]["output_lis_path"]) # Copy files to host diff --git a/biobb_dna/dna/dna_bimodality.py b/biobb_dna/dna/dna_bimodality.py index 78ba26b6..34dc5f27 100755 --- a/biobb_dna/dna/dna_bimodality.py +++ b/biobb_dna/dna/dna_bimodality.py @@ -143,7 +143,7 @@ def launch(self) -> int: # change directory to temporary folder original_directory = os.getcwd() - os.chdir(self.stage_io_dict.get("unique_dir")) + os.chdir(self.stage_io_dict.get("unique_dir", "")) # read input if self.stage_io_dict.get("in", {}).get("input_zip_file") is not None: @@ -151,7 +151,7 @@ def launch(self) -> int: with zipfile.ZipFile( self.stage_io_dict['in']['input_zip_file'], 'r') as zip_ref: - zip_ref.extractall(self.stage_io_dict.get("unique_dir")) + zip_ref.extractall(self.stage_io_dict.get("unique_dir", "")) data = load_data(Path(self.stage_io_dict['in']['input_csv_file']).name) diff --git a/biobb_dna/dna/dna_timeseries.py b/biobb_dna/dna/dna_timeseries.py index 19df4199..aeee5a18 100755 --- a/biobb_dna/dna/dna_timeseries.py +++ b/biobb_dna/dna/dna_timeseries.py @@ -214,10 +214,10 @@ def launch(self) -> int: # column series series_colfn = f"series_{self.helpar_name}_{col}" column_data.to_csv( - Path(self.stage_io_dict.get("unique_dir")) / f"{series_colfn}.csv") + Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv") # save table zf.write( - Path(self.stage_io_dict.get("unique_dir")) / f"{series_colfn}.csv", arcname=f"{series_colfn}.csv") + Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.csv", arcname=f"{series_colfn}.csv") fig, axs = plt.subplots(1, 1, dpi=300, tight_layout=True) reduced_data = column_data.iloc[::self.stride] @@ -229,10 +229,10 @@ def launch(self) -> int: "(base pair " f"{'step' if self.baselen==1 else ''} {col})") fig.savefig( - Path(self.stage_io_dict.get("unique_dir")) / f"{series_colfn}.jpg", format="jpg") + Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg", format="jpg") # save plot zf.write( - Path(self.stage_io_dict.get("unique_dir")) / f"{series_colfn}.jpg", arcname=f"{series_colfn}.jpg") + Path(self.stage_io_dict.get("unique_dir", "")) / f"{series_colfn}.jpg", arcname=f"{series_colfn}.jpg") plt.close() # columns histogram @@ -240,21 +240,21 @@ def launch(self) -> int: fig, axs = plt.subplots(1, 1, dpi=300, tight_layout=True) ybins, x, _ = axs.hist(column_data, bins=self.bins) pd.DataFrame({self.helpar_name: x[:-1], "density": ybins}).to_csv( - Path(self.stage_io_dict.get("unique_dir")) / f"{hist_colfn}.csv", + Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv", index=False) # save table zf.write( - Path(self.stage_io_dict.get("unique_dir")) / f"{hist_colfn}.csv", + Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.csv", arcname=f"{hist_colfn}.csv") axs.set_ylabel("Density") axs.set_xlabel(f"{self.helpar_name.capitalize()} ({self.hp_unit})") fig.savefig( - Path(self.stage_io_dict.get("unique_dir")) / f"{hist_colfn}.jpg", + Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg", format="jpg") # save plot zf.write( - Path(self.stage_io_dict.get("unique_dir")) / f"{hist_colfn}.jpg", + Path(self.stage_io_dict.get("unique_dir", "")) / f"{hist_colfn}.jpg", arcname=f"{hist_colfn}.jpg") plt.close() zf.close()