Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skothenhill-nv committed Dec 17, 2024
1 parent 5c97d41 commit b71b3f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 1 addition & 12 deletions sub-packages/bionemo-noodles/src/bionemo/noodles/nvfaidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, reader: PyIndexedMmapFastaReader, seqid: str, length: int) ->
- out of bounds indexing is truncated: query[1:999999999] will return a string from position 1 to the terminus.
- reversed slices return the empty string: query[999:1] is the empty string.
- empty slice returns the full string: query[:] is the full string of the sequence.
- beginning of slice is beyond the range of the contig, the empty string is returned.
Additionally there are convenience methods that you may find useful in the class definition.
Expand Down Expand Up @@ -178,18 +179,6 @@ def __init__(self, fasta_path: str | Path, faidx_path: Optional[str | Path] = No
raise ValueError("unreachable condition.")

self.records: Dict[str, PyFaidxRecord] = {record.name: record for record in self.reader.records()}
return
if ignore_existing_fai:
self.reader = PyIndexedMmapFastaReader(fasta_path, ignore_existing_fai=ignore_existing_fai)
elif faidx_path is not None:
self.reader = PyIndexedMmapFastaReader.from_fasta_and_faidx(fasta_path, faidx_path)
else:
# No faidx path is passed, ignore_existing is always False in this branch
# if the faidx exists, we use it
# if the faidx does not exist, we dont.
self.reader = PyIndexedMmapFastaReader(fasta_path, ignore_existing_fai=ignore_existing_fai)

self.records: Dict[str, PyFaidxRecord] = {record.name: record for record in self.reader.records()}

def __getitem__(self, seqid: str) -> SequenceAccessor: # noqa: D105
if seqid not in self.records:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ def _test_faidx_generic(faidx_obj):
# Should see this is out of bounds and return empty or throw an error
assert index["chr4"][17:17] == ""

assert index["chr4"][17:] == ""


def test_nvfaidx_python_interface(sample_fasta):
nvfaidx_index = NvFaidx(sample_fasta)
Expand Down

0 comments on commit b71b3f4

Please sign in to comment.