Skip to content

Commit

Permalink
Merge pull request #12 from glrs/refactor/ss3_file_handling
Browse files Browse the repository at this point in the history
Move paths to SampleFileHandler
  • Loading branch information
glrs authored Oct 31, 2024
2 parents 8d34714 + 6127f27 commit 1aec84f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
17 changes: 4 additions & 13 deletions lib/realms/smartseq3/ss3_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class SS3Sample(AbstractSample):
config (dict): Configuration settings.
status (str): Current status of the sample.
metadata (dict): Metadata for the sample.
project_dir (Path): Path to the parent project directory.
sample_dir (Path): Path to the sample directory.
sjob_manager (SlurmJobManager): Manager for submitting and monitoring Slurm jobs.
file_handler (SampleFileHandler): Handler for sample files.
"""
Expand Down Expand Up @@ -58,13 +56,6 @@ def __init__(self, sample_id, sample_data, project_info, config):
self._status = "pending" # other statuses: "processing", "completed", "failed"
self.metadata = None

# Define the parent project directory
self.project_dir = self.project_info.get("project_dir")

# Define the sample directory
# NOTE: This directory is not created yet. To be verified in the post_process method.
self.sample_dir = self.project_dir / self.id

if DEBUG:
self.sjob_manager = MockSlurmJobManager()
else:
Expand Down Expand Up @@ -209,8 +200,8 @@ def _collect_yaml_metadata(self):
"fastqs": {k: str(v) for k, v in fastqs.items() if v},
"read_setup": read_setup,
"ref": ref_paths,
"outdir": str(self.sample_dir),
"out_yaml": self.project_dir / f"{self.id}.yaml",
"outdir": str(self.file_handler.sample_dir),
"out_yaml": self.file_handler.project_dir / f"{self.id}.yaml",
}
except Exception as e:
logging.error(f"Error constructing metadata for sample {self.id}: {e}")
Expand Down Expand Up @@ -259,10 +250,10 @@ def _collect_slurm_metadata(self):
try:
metadata = {
"project_name": self.project_info["project_name"],
"project_dir": self.project_dir,
"project_dir": self.file_handler.project_dir,
# 'sample_id': self.id, # Temporarily not used, but might be used when we name everything after ngi
"plate_id": self.id, # self.sample_data.get('customer_name', ''),
"yaml_settings_path": self.project_dir / f"{self.id}.yaml",
"yaml_settings_path": self.file_handler.project_dir / f"{self.id}.yaml",
"zumis_path": self.config["zumis_path"],
}
except Exception as e:
Expand Down
8 changes: 3 additions & 5 deletions lib/realms/smartseq3/utils/sample_file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ def __init__(self, sample):
self.config = sample.config

# Define sample folder structure
self.base_dir = (
Path(self.config["smartseq3_dir"]) / "projects" / self.project_name
)
self.sample_dir = self.base_dir / self.sample_id
self.project_dir = sample.project_info.get("project_dir", "")
self.sample_dir = self.project_dir / self.sample_id
self.zumis_output_dir = self.sample_dir / "zUMIs_output"
self.stats_dir = self.sample_dir / "zUMIs_output" / "stats"
self.expression_dir = self.sample_dir / "zUMIs_output" / "expression"
Expand Down Expand Up @@ -90,7 +88,7 @@ def init_file_paths(self):
self.features_plot_fpath = self.stats_dir / f"{self.plate}.features.pdf"

# Files needed for processing
self.slurm_script_path = self.base_dir / f"{self.sample_id}_slurm_script.sh"
self.slurm_script_path = self.project_dir / f"{self.sample_id}_slurm_script.sh"
self.barcode_fpath = (
Path(self.config["smartseq3_dir"]) / "barcodes" / f"{self.barcode}.txt"
)
Expand Down

0 comments on commit 1aec84f

Please sign in to comment.