Skip to content

Commit

Permalink
Add genarkParser
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Feb 13, 2024
1 parent fadc7f2 commit 4dacd65
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/widgets/genarkDatasourceConfigurator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

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

function genarkDatasourceConfigurator() {

const url = 'https://hgdownload.soe.ucsc.edu/hubs/UCSC_GI.assemblyHubList.txt'
Expand All @@ -25,6 +27,8 @@ function genarkDatasourceConfigurator() {
'common name': {title: 'Common Name'},
},

parser: genarkParser

}
}

Expand Down
19 changes: 19 additions & 0 deletions js/widgets/utils/genarkParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const genarkParser =
{
parse: string => {
const lines = string.split('\n')
const headerLines = lines.filter(line => line.startsWith('#'))

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

// records
const records = lines.filter(line => !line.startsWith('#')).map(line => line.split(`\t`))

return records
}
};

export { genarkParser }

0 comments on commit 4dacd65

Please sign in to comment.