Skip to content

Commit

Permalink
optional order fasta file
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Feb 4, 2025
1 parent ec5e861 commit 2935e04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions bfabric_app_runner/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

- New input type `file` which replaces `file_scp` and preserves timestamps whenever possible and allows to create
symlinks instead of copying the file, as needed.
- `BfabricOrderFastaSpec.required` which allows specifying whether the order fasta is required or not

## \[0.0.14\] - 2025-01-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,29 @@ def prepare_dataset(self, spec: BfabricDatasetSpec) -> None:
dataset.write_csv(path=target_path, separator=spec.separator)

def prepare_order_fasta(self, spec: BfabricOrderFastaSpec) -> None:
# Determine the result file.
result_name = self._working_dir / spec.filename
result_name.parent.mkdir(exist_ok=True, parents=True)

# Find the order.
match spec.entity:
case "workunit":
workunit = Workunit.find(id=spec.id, client=self._client)
if not isinstance(workunit.container, Order):
raise ValueError(f"Workunit {workunit.id} is not associated with an order")
msg = f"Workunit {workunit.id} is not associated with an order"
if spec.required:
raise ValueError(msg)
else:
logger.warning(msg)
result_name.write_text("")
return
order = workunit.container
case "order":
order = Order.find(id=spec.id, client=self._client)
case _:
assert_never(spec.entity)

# Write the result into the file
result_name = self._working_dir / spec.filename
result_name.parent.mkdir(exist_ok=True, parents=True)
fasta_content = order.data_dict.get("fastasequence", "")
if fasta_content and fasta_content[-1] != "\n":
fasta_content += "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BfabricOrderFastaSpec(BaseModel):
id: int
entity: Literal["workunit", "order"]
filename: RelativeFilePath
required: bool = False

def resolve_filename(self, client: Bfabric) -> str:
return self.filename

0 comments on commit 2935e04

Please sign in to comment.