Skip to content

Commit f913c67

Browse files
committed
Enhance medulla page test with detailed data inspection and debugging
1 parent 628f4ee commit f913c67

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

vfbterms.py

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,25 @@ def format_synonyms(term):
189189

190190
def format_xrefs(term):
191191
refs = []
192-
if "xrefs" in term: # Check if xrefs exists in the dictionary
193-
for xref in term["xrefs"]: # Access xrefs using dictionary notation
194-
# Check if xref is a string or dictionary
195-
if isinstance(xref, dict):
196-
icon = ' <i class="fa fa-external-link"></i>' if xref.get("site", {}).get("icon") == "link" else ''
197-
refs.append(f'- <a href="{xref["link_base"]}{xref["accession"]}" target="_blank">{xref["site"]["label"]}</a>{icon}')
192+
if "xrefs" in term:
193+
for xref in term["xrefs"]:
194+
if isinstance(xref, str) and ":" in xref:
195+
db, accession = xref.split(":", 1)
196+
# The schema indicates xrefs should be objects with link_base and accession
197+
# We'll construct the link based on the database identifier
198+
if db == "InsectBrainDB":
199+
link_base = "https://insectbraindb.org/app/structures/"
200+
refs.append(f'- <a href="{link_base}{accession}" target="_blank">{db}</a>')
201+
else:
202+
# For other databases, just display the raw xref until we have proper link_base mapping
203+
refs.append(f'- {xref}')
204+
elif isinstance(xref, dict):
205+
# Handle cases where xref is already in schema format
206+
if "link_base" in xref and "accession" in xref:
207+
icon = ' <i class="fa fa-external-link"></i>' if xref.get("site", {}).get("icon") == "link" else ''
208+
link_text = xref.get("site", {}).get("label", xref.get("link_text", "Link"))
209+
refs.append(f'- <a href="{xref["link_base"]}{xref["accession"]}" target="_blank">{link_text}</a>{icon}')
198210
else:
199-
# Handle string xrefs or log them for debugging
200211
print(f"Unexpected xref format: {xref}")
201212
return '\n'.join(refs) if refs else 'None'
202213

@@ -310,51 +321,27 @@ def wrapStringInHTMLMac(term):
310321

311322
def test_medulla_page():
312323
"""Test full term page creation for medulla using actual VFB connection"""
313-
expected_content = """---
314-
title: "medulla [FBbt_00003748]"
315-
linkTitle: "medulla"
316-
tags: [Entity,Adult,Anatomy,Class,Nervous_system,Synaptic_neuropil,Synaptic_neuropil_domain,FBbt]
317-
content: [term]
318-
date: {current_date}
319-
images: []
320-
description: >
321-
The second optic neuropil, sandwiched between the lamina and the lobula complex. It is divided into 10 layers: 1-6 make up the outer (distal) medulla, the seventh (or serpentine) layer exhibits a distinct architecture and layers 8-10 make up the inner (proximal) medulla (Ito et al., 2014).
322-
weight: 10000
323-
sitemap_exclude: true
324-
canonicalUrl: "https://www.virtualflybrain.org/term/medulla-fbbt_00003748/"
325-
---
326-
327-
{note}
328-
329-
[Open **medulla** in **VFB**](https://v2.virtualflybrain.org/org.geppetto.frontend/geppetto?id=FBbt_00003748)
330-
331-
## Term Information
332-
333-
- **ID**: FBbt_00003748
334-
- **Name**: medulla
335-
- **Definition**: The second optic neuropil, sandwiched between the lamina and the lobula complex. It is divided into 10 layers: 1-6 make up the outer (distal) medulla, the seventh (or serpentine) layer exhibits a distinct architecture and layers 8-10 make up the inner (proximal) medulla (Ito et al., 2014).
336-
- **Type**: Entity, Adult, Anatomy, Class, Nervous_system, Synaptic_neuropil, Synaptic_neuropil_domain
337-
338-
## Classification
339-
- [synaptic neuropil domain](https://www.virtualflybrain.org/term/synaptic-neuropil-domain-fbbt_00040007) <span class="label types"><span class="label label-Synaptic_neuropil">Synaptic neuropil</span> <span class="label label-Nervous_system">Nervous system</span></span>
340-
341-
## Relationships
342-
- develops from [medulla anlage](https://www.virtualflybrain.org/term/medulla-anlage-fbbt_00001935) <span class="label types"><span class="label label-Nervous_system">Nervous system</span> <span class="label label-Larva">Larva</span></span>
343-
344-
## Cross References
345-
- [![Insect Brain DB](https://insectbraindb.org/app/assets/images/Megalopta_frontal.png) Insect Brain DB](https://insectbraindb.org/app/structures/38)
346-
- [medulla on Insect Brain DB](https://insectbraindb.org/app/structures/38)"""
347-
348-
# Get actual medulla data
349324
print("Fetching medulla data from VFB...")
350325
terms = vc.neo_query_wrapper.get_TermInfo(["FBbt_00003748"])
351326

352327
if terms.empty:
353328
print("ERROR: Could not fetch medulla data")
354329
return False
355330

331+
print("\nRaw terms data:")
332+
print(terms)
333+
print("\nColumns:")
334+
print(terms.columns)
335+
336+
# Process first row
337+
row = terms.iloc[0]
338+
print("\nFirst row data:")
339+
for col in terms.columns:
340+
print(f"\n{col}:")
341+
print(row[col])
342+
356343
# Generate actual content
357-
print("Generating medulla page...")
344+
print("\nGenerating medulla page...")
358345
import tempfile
359346
import os
360347

0 commit comments

Comments
 (0)