Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsolo1 committed Oct 31, 2023
1 parent 415490e commit 663a988
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 69 deletions.
4 changes: 1 addition & 3 deletions browser/src/ConstraintTable/GnomadConstraintTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ const GnomadConstraintTable = ({ constraint }: GnomadConstraintTableProps) => {
{constraintFlags.map((flag) => {
let flagDescription
if (flag in CONSTRAINT_FLAG_DESCRIPTIONS) {
{
/* @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message */
}
/* @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message */
flagDescription = CONSTRAINT_FLAG_DESCRIPTIONS[flag]
} else {
flagDescription = (
Expand Down
11 changes: 4 additions & 7 deletions browser/src/CoverageTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,21 @@ class CoverageTrack extends Component<CoverageTrackProps, CoverageTrackState> {
}

renderBars({ isPositionDefined, scaleCoverageMetric, scalePosition, totalBases, width }: any) {
const { datasets, height, datasetId } = this.props
const { datasets, height } = this.props
const { selectedMetric } = this.state

const barWidth = width / totalBases - 1

return datasets.map((dataset) => (
return datasets.map((dataset: any) => (
<g key={dataset.name}>
{dataset.buckets
.filter(
(bucket) =>
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
(bucket: any) =>
bucket[selectedMetric] !== undefined &&
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
bucket[selectedMetric] !== null &&
isPositionDefined(bucket.pos)
)
.map((bucket) => {
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
.map((bucket: any) => {
const barHeight = height - scaleCoverageMetric(bucket[selectedMetric])
const x = scalePosition(bucket.pos)
return (
Expand Down
30 changes: 15 additions & 15 deletions browser/src/VariantPage/HGDPPopulationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,23 @@ const addPopulationNames = (populations: any, datasetId: DatasetId) => {
})
}

function compareArrays(arr1: string[], arr2: string[]) {
const uniqueArr1 = new Set(arr1)
const uniqueArr2 = new Set(arr2)
// function compareArrays(arr1: string[], arr2: string[]) {
// const uniqueArr1 = new Set(arr1)
// const uniqueArr2 = new Set(arr2)

let areSame = true
// let areSame = true

for (let item of uniqueArr1) {
if (!uniqueArr2.has(item)) {
console.error(`Element "${item}" is in the first array but not in the second array.`)
areSame = false
}
}
// for (const item of uniqueArr1) {
// if (!uniqueArr2.has(item)) {
// console.error(`Element "${item}" is in the first array but not in the second array.`)
// areSame = false
// }
// }

if (!areSame) {
throw new Error("Population definitions don't match")
}
}
// if (!areSame) {
// throw new Error("Population definitions don't match")
// }
// }

const groupPopulations = (populations: any, datasetId: DatasetId) => {
const populationsById = populations.reduce(
Expand All @@ -252,7 +252,7 @@ const groupPopulations = (populations: any, datasetId: DatasetId) => {
const groupedPopulations = []
Object.keys(HGDP_POPULATION_GROUPS).forEach((group) => {
// @ts-ignore
compareArrays(HGDP_POPULATION_GROUPS[group], Object.keys(populationsById))
// compareArrays(HGDP_POPULATION_GROUPS[group], Object.keys(populationsById))
groupedPopulations.push({
id: group,
name: group,
Expand Down
9 changes: 3 additions & 6 deletions browser/src/VariantPage/VariantSiteQualityMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ const getMetricDataForSequencingType = ({
const metricValue = genomeOrExomeMetric && genomeOrExomeMetric.value

if (!metricValue) {
console.warn(`Could not determine metric value ${metricValue}`)
return null
throw new Error(`Could not determine metric value ${metricValue}`)
}

const { ac, an } = genomeOrExome
Expand Down Expand Up @@ -189,9 +188,8 @@ const getMetricDataForSequencingType = ({
const binValues = [histogram.n_smaller, ...histogram.bin_freq, histogram.n_larger]

return { binEdges, binValues, metricValue, description }
} else {
throw new Error(`Metric ${key} could not be found`)
}
throw new Error(`Metric ${key} could not be found`)
}

const prepareDataGnomadV4 = ({ metric, variant }: { metric: string; variant: Variant }) => {
Expand Down Expand Up @@ -248,9 +246,8 @@ const prepareDataGnomadV3 = ({ metric, genome }: { metric: string; genome: Seque
genomeBinValues: genomeMetrics && genomeMetrics.binValues,
genomeMetricValue: genomeMetrics && genomeMetrics.metricValue,
}
} else {
throw new Error(`Could not derive genome metrics`)
}
throw new Error(`Could not derive genome metrics`)
}

const prepareDataGnomadV2 = ({ metric, variant }: any) => {
Expand Down
3 changes: 1 addition & 2 deletions graphql-api/src/queries/coverage-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ const fetchCoverage = async (esClient: any, { index, contig, regions, bucketSize
],
}))
} catch (error) {
console.error('Error fetching coverage:', error)
throw error // Re-throwing the error to be handled by the caller or higher up in the call stack
throw new Error(`Couldn't fetch coverage, ${error}`)
}
}
// ================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ const fetchVariantById = async (esClient: any, variantIdOrRsid: any, subset: any
// @ts-ignore
name = renamePredictorMapping[id]
}
if (id == 'cadd') {
if (id === 'cadd') {
return { id: name, value: variant.in_silico_predictors.cadd.phred, flags: [] }
}
return { id: name, value: variant.in_silico_predictors[id].toPrecision(3), flags: [] }
}
throw new Error('In silico predictor not found in variant')
})
.filter((item) => item)

Expand Down Expand Up @@ -312,18 +313,10 @@ const shapeVariantSummary = (subset: any, context: any) => {
// Gene query
// ================================================================================================

const fetchVariantsByGene = async (esClient: any, gene: any, subset: any) => {
subset = 'all'

let exomeSubset = 'all'
let genomeSubset = 'all'

if (subset === 'tgp' || subset === 'hgdp') {
genomeSubset = subset
}
if (subset === 'non_ukb') {
exomeSubset = 'non_ukb'
}
const fetchVariantsByGene = async (esClient: any, gene: any, _subset: any) => {
const subset = 'all'
const exomeSubset = 'all'
const genomeSubset = 'all'

try {
const filteredRegions = gene.exons.filter((exon: any) => exon.feature_type === 'CDS')
Expand Down Expand Up @@ -385,25 +378,18 @@ const fetchVariantsByGene = async (esClient: any, gene: any, subset: any) => {

return shapedHits
} catch (error) {
console.error('Error fetching variants by gene:', error)
throw error // You can re-throw the error if needed or handle it accordingly.
throw new Error(`'Error fetching variants by gene:', ${error}`)
}
}

// ================================================================================================
// Region query
// ================================================================================================

const fetchVariantsByRegion = async (esClient: any, region: any, subset: any) => {
let exomeSubset = 'all'
let genomeSubset = 'all'

if (subset === 'tgp' || subset === 'hgdp') {
genomeSubset = subset
}
if (subset === 'non_ukb') {
exomeSubset = 'non_ukb'
}
const fetchVariantsByRegion = async (esClient: any, region: any, _subset: any) => {
const subset = 'all'
const exomeSubset = 'all'
const genomeSubset = 'all'

const hits = await fetchAllSearchResults(esClient, {
index: GNOMAD_V4_VARIANT_INDEX,
Expand Down Expand Up @@ -452,18 +438,11 @@ const fetchVariantsByRegion = async (esClient: any, region: any, subset: any) =>
// Transcript query
// ================================================================================================

const fetchVariantsByTranscript = async (esClient: any, transcript: any, subset: any) => {
subset = 'all'

let exomeSubset = 'all'
let genomeSubset = 'all'
const fetchVariantsByTranscript = async (esClient: any, transcript: any, _subset: any) => {
const subset = 'all'
const exomeSubset = 'all'
const genomeSubset = 'all'

if (subset === 'tgp' || subset === 'hgdp') {
genomeSubset = subset
}
if (subset === 'non_ukb') {
exomeSubset = 'non_ukb'
}
const filteredRegions = transcript.exons.filter((exon: any) => exon.feature_type === 'CDS')
const sortedRegions = filteredRegions.sort((r1: any, r2: any) => r1.xstart - r2.xstart)
const padding = 75
Expand Down

0 comments on commit 663a988

Please sign in to comment.