Last active
November 27, 2024 01:46
-
-
Save cmdcolin/2ef875fc19c5f164aad41bd330f1bb37 to your computer and use it in GitHub Desktop.
jbrowse 1 to jbrowse 2 nodejs script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require("fs"); | |
| const trackList = JSON.parse(fs.readFileSync("./trackList.json", "utf8")); | |
| const newTracks = []; | |
| const unconverted = []; | |
| function basicData(track) { | |
| return { | |
| name: track.key || track.label, | |
| trackId: track.label, | |
| assemblyNames: ["salmonella"], | |
| category: (track.category || track.metadata.category) | |
| ?.split("/") | |
| .map((t) => t.trim()), | |
| }; | |
| } | |
| // Only handles QuantitativeTracks and simple NCList FeatureTracks right now | |
| for (const track of trackList.tracks) { | |
| if (track.type.includes("XYPlot")) { | |
| newTracks.push({ | |
| ...basicData(track), | |
| type: "QuantitativeTrack", | |
| adapter: { | |
| type: "BigWigAdapter", | |
| bigWigLocation: { uri: track.urlTemplate }, | |
| }, | |
| }); | |
| } else if (track.storeClass.includes("NCList")) { | |
| newTracks.push({ | |
| ...basicData(track), | |
| type: "FeatureTrack", | |
| adapter: { | |
| type: "NCListAdapter", | |
| rootUrlTemplate: { uri: track.urlTemplate }, | |
| }, | |
| }); | |
| } else { | |
| unconverted.push(track); | |
| } | |
| } | |
| console.log( | |
| `failed to convert: ${unconverted.length} tracks, written to unconverted.json`, | |
| ); | |
| console.log(`converted: ${newTracks.length} tracks, written to config.json`); | |
| fs.writeFileSync("unconverted.json", JSON.stringify(unconverted, null, 2)); | |
| fs.writeFileSync( | |
| "config.json", | |
| JSON.stringify( | |
| { | |
| // this assembly is manual, replace it with your own | |
| assemblies: [ | |
| { | |
| name: "salmonella", | |
| sequence: { | |
| type: "ReferenceSequenceTrack", | |
| trackId: "salmonella_seq", | |
| adapter: { | |
| type: "IndexedFastaAdapter", | |
| fastaLocation: { | |
| uri: "salmonella.fa", | |
| }, | |
| faiLocation: { | |
| uri: "salmonella.fa.fai", | |
| }, | |
| }, | |
| }, | |
| }, | |
| ], | |
| tracks: newTracks, | |
| }, | |
| null, | |
| 2, | |
| ), | |
| ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from discussion thread here GMOD/jbrowse-components#3927