@@ -74,62 +74,91 @@ jobs:
7474 cd python-apollo
7575 export ARROW_GLOBAL_CONFIG_PATH=$(pwd)/test-data/local-apollo2-arrow.yml
7676 python3 -c "
77- import traceback, json, sys
77+ import traceback, json, sys, logging
78+ logging.basicConfig(level=logging.DEBUG)
7879 try:
7980 from apollo import ApolloInstance
81+ from apollo import util
82+ from BCBio import GFF
8083 wa = ApolloInstance('http://localhost:8080/apollo', 'admin@local.host', 'password')
8184
8285 print('=== Organisms ===')
8386 orgs = wa.organisms.get_organisms()
8487 for o in orgs:
8588 print(f\" {o.get('commonName')}: sequences={o.get('sequences')}\")
8689
87- print()
88- print('=== Attempting load_gff3 with full traceback ===')
89- print('Installed apollo version:', end=' ')
90- import apollo; print(getattr(apollo, '__version__', 'unknown'))
91- print('BCBio.GFF available:', end=' ')
92- try:
93- from BCBio import GFF
94- print('yes')
95- except ImportError as e:
96- print(f'NO - {e}')
97-
9890 print()
9991 print('=== Manual GFF3 parsing test ===')
100- from BCBio import GFF
10192 with open('test-data/mrna-top.gff') as f:
10293 for rec in GFF.parse(f):
10394 print(f'Record: {rec.id}, features: {len(rec.features)}')
104- for feat in rec.features[:2] :
95+ for feat in rec.features:
10596 print(f' Feature: {feat.id}, type: {feat.type}, loc: {feat.location}')
97+ print(f' Sub-features: {[(sf.type, sf.location) for sf in feat.sub_features]}')
10698
10799 print()
108- print('=== Manual addTranscript via python-apollo ===')
100+ print('=== Replicate load_gff3 step by step ===')
109101 wa.annotations.set_sequence('test_organism', 'Merlin')
110- result = wa.annotations.add_transcripts([{
111- 'location': {'fmin': 5000, 'fmax': 6000, 'strand': 1},
112- 'type': {'name': 'mRNA', 'cv': {'name': 'sequence'}},
113- 'children': [{
114- 'location': {'fmin': 5000, 'fmax': 6000, 'strand': 1},
115- 'type': {'name': 'exon', 'cv': {'name': 'sequence'}}
116- }]
117- }])
118- print(f'addTranscript result: {json.dumps(result, indent=2)[:500]}')
102+
103+ # Parse GFF3 and build Apollo JSON like load_gff3 does
104+ with open('test-data/mrna-top.gff') as f:
105+ for rec in GFF.parse(f):
106+ print(f'Processing record: {rec.id}')
107+ for feature in rec.features:
108+ print(f' Feature type: {feature.type}')
109+ try:
110+ apollo_data = util.yieldApolloData(feature)
111+ print(f' Apollo data: {json.dumps(apollo_data, indent=2, default=str)[:1000]}')
112+ except Exception as e:
113+ print(f' yieldApolloData FAILED: {e}')
114+ traceback.print_exc()
115+ continue
116+
117+ # Try sending as transcript
118+ try:
119+ print(f' Calling add_transcripts...')
120+ result = wa.annotations.add_transcripts([apollo_data])
121+ print(f' add_transcripts result: {json.dumps(result, indent=2, default=str)[:500]}')
122+ except Exception as e:
123+ print(f' add_transcripts FAILED: {type(e).__name__}: {e}')
124+ traceback.print_exc()
125+
126+ print()
127+ print('=== Test addFeature endpoint ===')
128+ with open('test-data/mrna-top.gff') as f:
129+ for rec in GFF.parse(f):
130+ for feature in rec.features:
131+ apollo_data = util.yieldApolloData(feature)
132+ try:
133+ print(f' Calling add_feature...')
134+ result = wa.annotations.add_feature(apollo_data)
135+ print(f' add_feature result: {json.dumps(result, indent=2, default=str)[:500]}')
136+ except Exception as e:
137+ print(f' add_feature FAILED: {type(e).__name__}: {e}')
138+ traceback.print_exc()
119139
120140 print()
121- print('=== Full load_gff3 attempt with traceback ===')
141+ print('=== Remote API test ===')
122142 try:
123- feature_data = wa.annotations.load_gff3('test_organism', 'test-data/mrna-top.gff')
124- print(f'load_gff3 returned: {feature_data}')
143+ import tempfile, tarfile, glob
144+ with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive:
145+ with tarfile.open(archive.name, mode='w:gz') as tar:
146+ for file in glob.glob('test-data/dataset_1_files/data/*'):
147+ tar.add(file, arcname=file.replace('test-data/dataset_1_files/data/', './'))
148+ print(f' Archive contents:')
149+ with tarfile.open(archive.name, mode='r:gz') as tar:
150+ for m in tar.getmembers()[:10]:
151+ print(f' {m.name}')
152+ result = wa.remote.add_organism('diag_remote_org', archive)
153+ print(f' add_organism result: {json.dumps(result, indent=2, default=str)[:500]}')
125154 except Exception as e:
126- print(f'load_gff3 raised : {type(e).__name__}: {e}')
155+ print(f' remote add_organism FAILED : {type(e).__name__}: {e}')
127156 traceback.print_exc()
128157
129158 except Exception as e:
130159 print(f'DIAGNOSTIC FAILED: {type(e).__name__}: {e}')
131160 traceback.print_exc()
132- " || true
161+ " 2>&1 || true
133162
134163 echo ""
135164 echo "=== Apollo ERROR/WARN log lines ==="
0 commit comments