Skip to content

Commit

Permalink
fix: fix guard condition in aminoAcidChange()
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Jun 19, 2020
1 parent 1e95f2f commit 978a9f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/web/src/algorithms/getAllAminoAcidChanges.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { inRange } from 'lodash'

import { GeneMapDatum } from './geneMap'
import { getCodon } from './codonTable'

import { Base } from './run'

export function aminoAcidChange(pos: number, queryAllele: string, refSequence: string, gene: GeneMapDatum) {
// check that the positions is infact part of this gene
if (pos < gene.start && pos >= gene.end) {
if (inRange(pos, gene.start, gene.end)) {
return undefined
}

Expand All @@ -14,7 +16,9 @@ export function aminoAcidChange(pos: number, queryAllele: string, refSequence: s
const codon = (pos - gene.start + 1 - frame) / 3
// pull out the codons and construct the query codon by inserting the allele
const refCodon = refSequence.substring(pos - frame, pos - frame + 3)
const queryCodon = refCodon.substring(0, frame) + queryAllele + refCodon.substring(frame + 1, 3)
const queryBegin = refCodon.substring(0, frame)
const queryEnd = refCodon.substring(frame + 1, 3)
const queryCodon = queryBegin + queryAllele + queryEnd

const refAA = getCodon(refCodon)
const queryAA = getCodon(queryCodon)
Expand Down

0 comments on commit 978a9f6

Please sign in to comment.