-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
ConfigurationReference, | ||
readConfObject, | ||
} from '@jbrowse/core/configuration' | ||
import { getSession } from '@jbrowse/core/util' | ||
import { BaseConnectionModelFactory } from '@jbrowse/core/pluggableElementTypes/models' | ||
import { types } from 'mobx-state-tree' | ||
import configSchema from './configSchema' | ||
|
||
import { fetchJb1 } from './jb1ConfigLoad' | ||
import { convertTrackConfig } from './jb1ToJb2' | ||
import PluginManager from '@jbrowse/core/PluginManager' | ||
|
||
export default function (pluginManager: PluginManager) { | ||
return types | ||
.compose( | ||
'JBrowse1Connection', | ||
BaseConnectionModelFactory(pluginManager), | ||
types.model({ | ||
configuration: ConfigurationReference(configSchema), | ||
type: types.literal('JBrowse1Connection'), | ||
}), | ||
) | ||
|
||
.actions(self => ({ | ||
connect() { | ||
const dataDirLocation = readConfObject( | ||
self.configuration, | ||
'dataDirLocation', | ||
) | ||
const session = getSession(self) | ||
fetchJb1(dataDirLocation) | ||
.then(config => { | ||
const assemblyName = readConfObject( | ||
self.configuration, | ||
'assemblyNames', | ||
)[0] | ||
if (!assemblyName) { | ||
throw new Error('assembly name required for JBrowse 1 connection') | ||
} | ||
const assemblyConf = session.assemblies.find( | ||
assembly => readConfObject(assembly, 'name') === assemblyName, | ||
) | ||
if (!assemblyConf) { | ||
throw new Error(`Assembly "${assemblyName}" not found`) | ||
} | ||
const sequenceAdapter = readConfObject(assemblyConf, [ | ||
'sequence', | ||
'adapter', | ||
]) | ||
|
||
// @ts-ignore | ||
const jb2Tracks = config.tracks?.map(jb1Track => { | ||
const jb2Track = convertTrackConfig( | ||
jb1Track, | ||
config.dataRoot || '', | ||
sequenceAdapter, | ||
) | ||
|
||
// @ts-ignore | ||
jb2Track.assemblyNames = [assemblyName] | ||
return jb2Track | ||
}) | ||
|
||
self.setTrackConfs(jb2Tracks) | ||
}) | ||
.catch(error => { | ||
console.error(error) | ||
session.notify( | ||
`There was a problem connecting to the JBrowse 1 data directory "${self.name}". Please make sure you have entered a valid location. The error that was thrown is: "${error}"`, | ||
'error', | ||
) | ||
session.breakConnection(self.configuration) | ||
}) | ||
}, | ||
})) | ||
} |
This file contains 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
4 changes: 2 additions & 2 deletions
4
...ive-view/src/ServerSideRenderedContent.js → ...ve-view/src/ServerSideRenderedContent.tsx
This file contains 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
This file contains 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
This file contains 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