Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Created April 22, 2025 17:02
Show Gist options
  • Save cmdcolin/79e1a9bc55e24e5b0b42903378aa5e0c to your computer and use it in GitHub Desktop.
Save cmdcolin/79e1a9bc55e24e5b0b42903378aa5e0c to your computer and use it in GitHub Desktop.
b73_converter.ts
import fs from 'fs'
const tracks = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')) as {
tracks: any[]
}
const asm = 'B73'
const assemblyNames = [asm]
const base = 'https://jbrowse.maizegdb.org/B73/'
console.log(
JSON.stringify(
{
assemblies: [
{
name: 'B73',
sequence: {
type: 'ReferenceSequenceTrack',
trackId: 'B73-ReferenceSequenceTrack',
adapter: {
type: 'IndexedFastaAdapter',
uri: `${base}/data/B73v5.fasta`,
},
},
},
],
tracks: tracks.tracks
.map(t => {
if (t.urlTemplates) {
return {
name: t.key,
trackId: t.label,
type: 'MultiQuantitativeTrack',
category: t.category.split('/'),
assemblyNames,
adapter: {
type: 'MultiWiggleAdapter',
subadapters: t.urlTemplates.map(f => {
console.error({ f })
return {
...f,
type: 'BigWigAdapter',
uri: f.url,
source: f.name,
}
}),
},
}
} else if (
t.urlTemplate.endsWith('bw') ||
t.urlTemplate.endsWith('.bigwig')
) {
return {
name: t.key,
trackId: t.label,
type: 'QuantitativeTrack',
category: t.category.split('/'),
assemblyNames,
adapter: {
type: 'BigWigAdapter',
uri: `${base}/${t.urlTemplate}`,
},
}
} else if (t.urlTemplate.endsWith('trackData.json')) {
return {
name: t.key,
trackId: t.label,
type: 'FeatureTrack',
category: t.category.split('/'),
assemblyNames,
adapter: {
type: 'NCListAdapter',
rootUrlTemplate: {
uri: `${base}/${t.urlTemplate}`,
},
},
}
} else if (t.urlTemplate.endsWith('.bb')) {
return {
name: t.key,
trackId: t.label,
type: 'FeatureTrack',
category: t.category.split('/'),
assemblyNames,
adapter: {
type: 'BigBedAdapter',
uri: `${base}/${t.urlTemplate}`,
},
}
} else {
return undefined
}
})
.filter(f => !!f),
},
null,
2,
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment