Skip to content

Commit 1f7a3f3

Browse files
Shaun Mahonyclaude
andcommitted
Fix match result links and make source tags link to database homepage
- JASPAR sync now always sets urlPattern and version on the ReferenceDatabase document (not just on first creation), so existing databases that predate the urlPattern field get backfilled on next sync - Processor builds dbHomeUrl (derived from urlPattern origin) and sets it on each match entry alongside dbUrl - Match name and dbId badge link to the specific motif page (dbUrl) - Blue source tag (e.g. "JASPAR") now links to the database homepage (dbHomeUrl) instead of the motif page - Add dbHomeUrl field to MatchEntry type - Legacy two-part format also sets dbHomeUrl for JASPAR Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 108b8e1 commit 1f7a3f3

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

web/src/components/results/MatchTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ function MatchRow({
312312
)
313313
)}
314314
{match.dbSource && (
315-
match.dbUrl ? (
315+
match.dbHomeUrl ? (
316316
<a
317-
href={match.dbUrl}
317+
href={match.dbHomeUrl}
318318
target="_blank"
319319
rel="noopener noreferrer"
320320
className="text-xs text-white bg-blue-500 px-1.5 py-0.5 rounded hover:bg-blue-600 transition-colors"

web/src/lib/jaspar/sync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export async function syncJaspar(options: SyncOptions = {}): Promise<SyncResult>
143143
lastSyncedAt: new Date(),
144144
motifCount,
145145
taxonGroups: storedTaxonGroups,
146+
version: "2024",
147+
urlPattern: "https://jaspar.elixir.no/matrix/{id}",
146148
}
147149
);
148150

web/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface MatchEntry {
6969
dbSource?: string; // e.g. "JASPAR"
7070
dbId?: string; // e.g. "MA0139.1"
7171
dbUrl?: string; // e.g. "https://jaspar.elixir.no/matrix/MA0139.1"
72+
dbHomeUrl?: string; // e.g. "https://jaspar.elixir.no"
7273
dbCollection?: string; // e.g. "CORE"
7374
}
7475

web/worker/processor.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,21 @@ export async function processStampJob(job: BullJob<StampJobData>): Promise<void>
9595
inputMotifMap.set(m.name, m.matrix);
9696
}
9797

98-
// Build URL pattern lookup from selected databases
98+
// Build URL pattern and home URL lookups from selected databases
9999
const urlPatternMap = new Map<string, string>();
100+
const dbHomeUrlMap = new Map<string, string>();
100101
if (matching.databases && matching.databases.length > 0) {
101102
const slugs = matching.databases.map((d) => d.slug);
102103
const refDbs = await ReferenceDatabase.find({ slug: { $in: slugs } }).lean() as Array<{ source?: string; urlPattern?: string }>;
103104
for (const db of refDbs) {
104105
if (db.source && db.urlPattern) {
105-
urlPatternMap.set(db.source.toUpperCase(), db.urlPattern);
106+
const key = db.source.toUpperCase();
107+
urlPatternMap.set(key, db.urlPattern);
108+
try {
109+
dbHomeUrlMap.set(key, new URL(db.urlPattern).origin);
110+
} catch {
111+
// If urlPattern isn't a valid URL, skip home URL
112+
}
106113
}
107114
}
108115
}
@@ -122,17 +129,23 @@ export async function processStampJob(job: BullJob<StampJobData>): Promise<void>
122129
entry.dbSource = dbSource;
123130
entry.dbId = matrixId;
124131
entry.name = displayName;
125-
const pattern = urlPatternMap.get(dbSource.toUpperCase());
132+
const sourceKey = dbSource.toUpperCase();
133+
const pattern = urlPatternMap.get(sourceKey);
126134
if (pattern) {
127135
entry.dbUrl = pattern.replace("{id}", matrixId);
128136
}
137+
const homeUrl = dbHomeUrlMap.get(sourceKey);
138+
if (homeUrl) {
139+
entry.dbHomeUrl = homeUrl;
140+
}
129141
} else {
130142
// Legacy two-part format: "MA0139.1::CTCF"
131143
const [matrixId, ...rest] = parts;
132144
const displayName = rest.join("::");
133145
entry.dbId = matrixId;
134146
entry.dbSource = "JASPAR";
135147
entry.dbUrl = `https://jaspar.elixir.no/matrix/${matrixId}`;
148+
entry.dbHomeUrl = "https://jaspar.elixir.no";
136149
entry.name = displayName || matrixId;
137150
}
138151
}

0 commit comments

Comments
 (0)