File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -442,6 +442,22 @@ impl PyRecord {
442442 ) ,
443443 }
444444 }
445+ fn __getitem__ ( & self , py : Python < ' _ > , tag : & str ) -> PyResult < PyObject > {
446+ let features = self . features ( py) ;
447+ if features. inner . contains_key ( tag) {
448+ // 1. Get the Bound<'_, PyFeatureInfo>
449+ // 2. Use .into_any() to get Bound<'_, PyAny>
450+ // 3. Use .unbind() to get PyObject
451+ return features. __getitem__ ( tag, py) . map ( |b| b. into_any ( ) . unbind ( ) ) ;
452+ }
453+
454+ let sequences = self . sequences ( py) ;
455+ if sequences. inner . contains_key ( tag) {
456+ return sequences. __getitem__ ( tag, py) . map ( |b| b. into_any ( ) . unbind ( ) ) ;
457+ }
458+
459+ Err ( PyKeyError :: new_err ( tag. to_string ( ) ) )
460+ }
445461}
446462//parse genbank function - returns the RecordCollection, good for fna and metadata from source
447463#[ pyfunction]
Original file line number Diff line number Diff line change 77import pytest
88
99
10- # --- FIXTURES: Generating Mock Data ---
10+ # FIXTURES: Generating Mock Data ---
1111@pytest .fixture
1212def mock_gbk (tmp_path ):
1313 """Creates a minimal valid GenBank file."""
@@ -81,7 +81,6 @@ def mock_blast_tab(tmp_path):
8181 return str (path )
8282
8383
84- < << << << HEAD
8584def test_gbk_loader_aliases (mock_gbk ):
8685 """Verify all specialized GBK loaders return a valid collection"""
8786 # Test all three aliases to ensure they point to the correct InternalRecord::Gbk logic
@@ -93,12 +92,12 @@ def test_gbk_loader_aliases(mock_gbk):
9392
9493 for load_func in loaders :
9594 collection = load_func (mock_gbk )
96- assert "source_1" in collection .keys ()
95+ keys = list (collection .keys ())
96+
97+ # This checks if "source_1" is either the key itself (FNA)
98+ # or the prefix of the key (FAA/FFN)
99+ assert any (k .startswith ("source_1" ) for k in keys ), f"Failed on { load_func .__name__ } "
97100 assert len (collection .keys ()) > 0
98- assert "SequenceCollection" in repr (collection )
99- == == == =
100- import os
101- > >> >> >> 505 cee7 (final branch fixes )
102101
103102
104103def test_gbk_count_function (mock_gbk ):
You can’t perform that action at this time.
0 commit comments