Skip to content

Commit

Permalink
group mutations follow same general mutation format
Browse files Browse the repository at this point in the history
  • Loading branch information
atc3 committed Jan 18, 2022
1 parent 5755610 commit 3ab374d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 5 additions & 3 deletions services/server/cg_server/query/group_mutation_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def query_group_mutation_frequencies(conn, req):
table_name = "{group}_frequency_{mutation_type}_mutation".format(
group=group, mutation_type=mutation_type
)
mutation_table_name = "{mutation_type}_mutation".format(mutation_type=mutation_type)
mutation_cols = ["pos", "ref", "alt", "mutation_name"]
mutation_table_name = "{mutation_type}_mutation".format(
mutation_type=mutation_type
)
mutation_cols = ["pos", "ref", "alt", "mutation_name", "mutation_str"]
if mutation_type == "gene_aa":
mutation_cols = ["gene",] + mutation_cols
elif mutation_type == "protein_aa":
Expand Down Expand Up @@ -55,7 +57,7 @@ def query_group_mutation_frequencies(conn, req):

res = pd.DataFrame.from_records(
cur.fetchall(),
columns=["name", "count", "fraction", "mutation_id",] + mutation_cols,
columns=["name", "count", "fraction", "mutation_id"] + mutation_cols,
)

# print(res)
Expand Down
23 changes: 17 additions & 6 deletions src/components/GroupReport/MutationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import { format } from 'd3-format';

import { config } from '../../config';
import { getAllGenes, getAllProteins } from '../../utils/gene_protein';
import { formatMutation } from '../../utils/mutationUtils';
import { reds, mutationColorArray } from '../../constants/colors';
import { ASYNC_STATES, PLOT_DOWNLOAD_OPTIONS } from '../../constants/defs.json';
import {
ASYNC_STATES,
PLOT_DOWNLOAD_OPTIONS,
DNA_OR_AA,
} from '../../constants/defs.json';

import GroupSearch from './GroupSearch';
import EmptyPlot from '../Common/EmptyPlot';
Expand Down Expand Up @@ -261,17 +266,16 @@ const MutationListContent = observer(() => {
// Unique mutations
.filter(
(v, i, a) =>
a.findIndex(
(element) => element.mutation_name === v.mutation_name
) === i
a.findIndex((element) => element.mutation_str === v.mutation_str) ===
i
)
.map((featureMutation) => {
// Find fractional frequencies for each group
const freqs = [];
groupDataStore.selectedGroups.forEach((group) => {
const matchingMutation = groupFeatureMutations.find(
(mut) =>
mut.mutation_name === featureMutation.mutation_name &&
mut.mutation_str === featureMutation.mutation_str &&
mut.name === group
);
// 0 if the mutation record isn't found
Expand All @@ -281,7 +285,13 @@ const MutationListContent = observer(() => {
});

return {
mutation_name: featureMutation.mutation_name,
// mutation_name: featureMutation.mutation_name,
mutation_name: formatMutation(
featureMutation.mutation_str,
groupDataStore.groupMutationType === 'dna'
? DNA_OR_AA.DNA
: DNA_OR_AA.AA
),
pos: featureMutation.pos,
ref: featureMutation.ref,
alt: featureMutation.alt,
Expand Down Expand Up @@ -342,6 +352,7 @@ const MutationListContent = observer(() => {
groupDataStore.groupMutationType === 'dna'
? mut.mutation_name
: mut.mutation_name.split(':')[1];

rowItems.push(
<MutationListRow
key={`group-mut-${feature.name}-${mut.mutation_name}`}
Expand Down

0 comments on commit 3ab374d

Please sign in to comment.