<commit_before>from flask import render_template as template
from flask_classful import FlaskView
from flask_login import current_user
from models import Protein
from models import Mutation


class MutationView(FlaskView):

    def show(self, refseq, position, alt):

        protein = Protein.query.filter_by(refseq=refseq).first_or_404()

        mutation = Mutation.query.filter_by(
            protein=protein,
            position=int(position),
            alt=alt
        ).first_or_404()

        # in case we also want to show also non-confirmed mutations:
        """
        from database import get_or_create

        mutation, _ = get_or_create(
            Mutation,
            protein=protein,
            # setting id directly is easier than forcing update outside session
            protein_id=protein.id,
            position=int(position),
            alt=alt
        )
        """
        datasets = []

        sources_with_mutation = mutation.sources_dict

        for source in mutation.source_fields:
            model = mutation.get_source_model(source)
            datasets.append({
                'filter': 'Mutation.sources:in:' + source,<commit_msg>Switch back to showing novel mutations for consistency<commit_after>from flask import render_template as template
from flask_classful import FlaskView
from flask_login import current_user
from models import Protein
from models import Mutation
from database import get_or_create


class MutationView(FlaskView):

    def show(self, refseq, position, alt):

        protein = Protein.query.filter_by(refseq=refseq).first_or_404()

        """
        mutation = Mutation.query.filter_by(
            protein=protein,
            position=int(position),
            alt=alt
        ).first_or_404()
        """

        mutation, _ = get_or_create(
            Mutation,
            protein=protein,
            # setting id directly is easier than forcing update outside session
            protein_id=protein.id,
            position=int(position),
            alt=alt
        )
        datasets = []

        sources_with_mutation = mutation.sources_dict

        for source in mutation.source_fields:
            model = mutation.get_source_model(source)
            datasets.append({
                'filter': 'Mutation.sources:in:' + source,
{'fraction_non_alphanumeric': 0.07182795698924731, 'fraction_numerical': 0.005161290322580645, 'mean_word_length': 2.28995756718529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6057707', 'n_tokens_mistral': 637, 'n_tokens_neox': 590, 'n_words': 158}