-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Genetics] refactor: move variant summary to ts with graphql query ty…
…pes (#269)
- Loading branch information
1 parent
9b2c123
commit 6720ef2
Showing
10 changed files
with
133 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare module '*.graphql' { | ||
import { DocumentNode } from 'graphql'; | ||
const Schema: DocumentNode; | ||
|
||
export default Schema; | ||
} | ||
|
||
declare module '*.gql' { | ||
import { DocumentNode } from 'graphql'; | ||
const Schema: DocumentNode; | ||
|
||
export default Schema; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
File renamed without changes.
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,60 @@ | ||
import { format } from 'd3-format'; | ||
|
||
/* | ||
Example usage: | ||
const comparatorDiseaseName = generateComparator(d => d.disease.name); | ||
*/ | ||
export const generateComparator = | ||
<T, U>(accessor: (d: T) => U) => | ||
(a: T, b: T) => { | ||
const aValue = accessor(a); | ||
const bValue = accessor(b); | ||
return aValue > bValue ? 1 : aValue === bValue ? 0 : -1; | ||
}; | ||
|
||
export const getData = ( | ||
data?: { [k: string]: any }, | ||
property?: string | ||
): object | boolean => { | ||
if (!data || Object.keys(data).length === 0) return false; | ||
if (!property) return data; | ||
if (hasData(data, property)) return data[property]; | ||
return false; | ||
}; | ||
|
||
export const hasData = (data: { [k: string]: any }, property: string) => { | ||
if (data && data[property]) return true; | ||
return false; | ||
}; | ||
|
||
type D3FormatNumberLike = number | { valueOf(): number }; | ||
export const commaSeparate: (n: D3FormatNumberLike) => string = format(','); | ||
export const safeCommaSeparate = (n?: D3FormatNumberLike | null) => | ||
n ? commaSeparate(n) : ''; | ||
|
||
export const sanitize = (str: string) => str.replace(/[^a-zA-Z0-9]/g, ''); | ||
|
||
interface TraitAuthorYearStudyInfo { | ||
traitReported: string; | ||
pubAuthor: string; | ||
pubDate: string; | ||
} | ||
export const traitAuthorYear = (s: TraitAuthorYearStudyInfo) => | ||
`${s.traitReported} (${s.pubAuthor}, ${new Date(s.pubDate).getFullYear()})`; | ||
|
||
export const isGreaterThanZero = (arrayLength: number) => { | ||
return arrayLength > 0; | ||
}; | ||
|
||
export const getPhenotypeId = (phenotypeId: string) => | ||
phenotypeId.includes('^') | ||
? phenotypeId.slice(phenotypeId.lastIndexOf('^') + 1) | ||
: phenotypeId; | ||
|
||
export const getSpliceId = (phenotypeId: string) => | ||
phenotypeId.includes('^') | ||
? phenotypeId.slice(0, phenotypeId.lastIndexOf('^')) | ||
: null; | ||
|
||
// Constants | ||
export const SIGNIFICANCE = -Math.log10(5e-8); |
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