Skip to content

Commit

Permalink
Modal table now presents data
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Feb 13, 2024
1 parent 4dacd65 commit f6a28e6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 42 deletions.
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import FileLoadManager from "./widgets/fileLoadManager.js"
import FileLoadWidget from "./widgets/fileLoadWidget.js"
import * as Utils from './widgets/utils.js'
import Globals from "./globals.js"
import {createGenomeWidgets, initializeGenomeWidgets, loadGenome} from './genomeWidgets.js'
import {createGenomeWidgets, initializeGenomeWidgets, loadGenome} from './widgets/genomeWidgets.js'
import {createShareWidgets, shareWidgetConfigurator} from './shareWidgets.js'
import {sessionURL} from './shareHelper.js'
import {createSaveImageWidget} from './saveImageWidget.js'
Expand Down
31 changes: 17 additions & 14 deletions js/widgets/genarkDatasourceConfigurator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

// accession assembly scientific name common name taxonId GenArk clade
import {genarkParser} from "./utils/genarkParser.js"
import {genarkParser} from "./genarkParser.js"

const genarkColumns =
[
'accession',
'assembly',
'scientificName',
'commonName',
'taxonId',
'genArkClade',

]

function genarkDatasourceConfigurator() {

Expand All @@ -9,27 +20,19 @@ function genarkDatasourceConfigurator() {
return {
isJSON: false,
url,
columns:
[
'accession',
'assembly',
'scientific name',
'common name',
'taxonId',
'GenArk clade',

],
columns: genarkColumns,
columnDefs:
{
accession: {title: 'Accession'},
assembly: {title: 'Assembly'},
'scientific name': {title: 'Scientific Name'},
'common name': {title: 'Common Name'},
scientificName: {title: 'Scientific Name'},
commonName: {title: 'Common Name'},
genArkClade: {title: 'GenArk clade'},
},

parser: genarkParser

}
}

export {genarkDatasourceConfigurator}
export {genarkDatasourceConfigurator, genarkColumns}
32 changes: 32 additions & 0 deletions js/widgets/genarkParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { genarkColumns } from "./genarkDatasourceConfigurator.js"

const genarkParser =
{
parse: string => {
const lines = string.split('\n')

// columns
// const headerLines = lines.filter(line => line.startsWith('#'))
// const columns = headerLines.pop().split('\t')
// const cooked = columns.shift().split('').filter(char => (/[a-zA-Z]/).test(char)).join('')
// columns.unshift(cooked)

// records
let dataLines = lines.filter(line => !line.startsWith('#')).map(line => line.split(`\t`))
dataLines = dataLines.filter(tokens => 6 === tokens.length)

const records = []
for (const tokens of dataLines) {
const record = {}
for (let i = 0; i < tokens.length; i++) {
record[ genarkColumns[ i ] ] = tokens[ i ]
}

records.push(record)
}

return records
}
};

export { genarkParser }
16 changes: 8 additions & 8 deletions js/genomeWidgets.js → js/widgets/genomeWidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
* THE SOFTWARE.
*/

import {ModalTable, GenericDataSource} from '../node_modules/data-modal/src/index.js'
import Globals from "./globals.js"
import AlertSingleton from "./widgets/alertSingleton.js"
import {createURLModal} from "./widgets/urlModal.js"
import FileLoadManager from "./widgets/fileLoadManager.js"
import FileLoadWidget from "./widgets/fileLoadWidget.js"
import * as Utils from './widgets/utils.js'
import {genarkDatasourceConfigurator} from "./widgets/genarkDatasourceConfigurator.js"
import {ModalTable, GenericDataSource} from '../../node_modules/data-modal/src/index.js'
import Globals from "../globals.js"
import AlertSingleton from "./alertSingleton.js"
import {createURLModal} from "./urlModal.js"
import FileLoadManager from "./fileLoadManager.js"
import FileLoadWidget from "./fileLoadWidget.js"
import * as Utils from './utils.js'
import {genarkDatasourceConfigurator} from "./genarkDatasourceConfigurator.js"

const MAX_CUSTOM_GENOMES = 10

Expand Down
19 changes: 0 additions & 19 deletions js/widgets/utils/genarkParser.js

This file was deleted.

0 comments on commit f6a28e6

Please sign in to comment.