Ejemplo n.º 1
0
    def test_affected_unknown(self):
        """ Test including affected unknown for mother of target to show it increases breast cancer risk. """
        pedigree = deepcopy(self.pedigree)
        target = pedigree.get_target()
        mother = pedigree.get_person(target.mothid)
        mother.yob = str(self.year - 55)
        mother.age = "55"
        calcs1 = Predictions(pedigree, cwd=self.cwd)

        def get_c80(calcs):
            for c in calcs.cancer_risks:
                if c.get('age') == 80:
                    return c['breast cancer risk']['decimal']
            return None

        # add affected unknown to mother
        mother.cancers = Cancers(bc1=Cancer("AU"),
                                 bc2=Cancer(),
                                 oc=Cancer(),
                                 prc=Cancer(),
                                 pac=Cancer())
        calcs2 = Predictions(pedigree, cwd=self.cwd)
        self.assertGreater(
            get_c80(calcs2), get_c80(calcs1),
            'Mother affected unknown increases BC risk in target')
Ejemplo n.º 2
0
 def test_calcs_validation_err(self):
     """ Test invalid calculation type raise ValidationError. """
     target = Female("FAM1", "F0", "001", "002", "003", target="1", age="20",
                     yob=str(date.today().year-20), gtests=CanRiskGeneticTests.default_factory())
     pedigree = CanRiskPedigree(people=[target])
     with self.assertRaisesRegex(ValidationError, r"Unknown calculation requested: dribble"):
         Predictions(pedigree, model_settings=settings.OC_MODEL, calcs=['dribble'])
Ejemplo n.º 3
0
 def test_bws_model_err(self):
     ''' Test ModelError raised because of pedigree file with only one twin. '''
     target = Female("FAM1", "F0", "001", "002", "003", target="1", age="20", mztwin="1",
                     yob=str(date.today().year-20), gtests=CanRiskGeneticTests.default_factory())
     pedigree = CanRiskPedigree(people=[target])
     with self.assertRaisesRegex(ModelError, r"ERRORS IN THE PEDIGREE FILE"):
         Predictions(pedigree)
Ejemplo n.º 4
0
 def test_subproces_err(self):
     """ Test subprocess raises an error when the fortran can not be run. """
     pedigree = deepcopy(self.pedigree)
     PedigreeFile.validate(pedigree)
     with self.assertRaises(FileNotFoundError):
         model_settings = settings.BC_MODEL
         model_settings['HOME'] = 'xyz'
         Predictions(pedigree, cwd=self.cwd, model_settings=model_settings)
Ejemplo n.º 5
0
    def test_10yr_range_risk(self):
        """ Test ten year range (40-49) risk calculation matches the risk to 50 for a 40 year old. """
        pedigree = deepcopy(self.pedigree)
        PedigreeFile.validate(pedigree)
        calcs1 = Predictions(pedigree, cwd=self.cwd)

        t = pedigree.get_target()
        t.age = '40'
        calcs2 = Predictions(pedigree, cwd=self.cwd)

        c50 = None
        for c in calcs2.cancer_risks:
            if c.get('age') == 50:
                c50 = c

        self.assertEqual(
            calcs1.ten_yr_cancer_risk[0]['breast cancer risk']['decimal'],
            c50['breast cancer risk']['decimal'])
Ejemplo n.º 6
0
 def test_pedigree_range_baseline(self):
     """ Test pedigree for baseline time range (e.g. lifetime, 10yr range) risk calculation. """
     p1 = deepcopy(self.pedigree)
     PedigreeFile.validate(p1)
     calcs = Predictions(p1, cwd=self.cwd, run_risks=False)
     range_baseline = RangeRiskBaseline(calcs, 40, 50, "10 YR RANGE BASELINE")
     p2 = range_baseline._get_pedi()
     self.assertEqual(len(p2.people), 1)
     self.assertEqual(p2.get_target().age, 40)
     self.assertNotEqual(p1.get_target().age, p2.get_target().age)
Ejemplo n.º 7
0
 def test_pedigree_remaining_lifetime(self):
     """ Test pedigree for remaining lifetime risk calculation. """
     p1 = deepcopy(self.pedigree)
     PedigreeFile.validate(p1)
     calcs = Predictions(p1, cwd=self.cwd, run_risks=False)
     self.assertTrue(calcs.pedi.is_carrier_probs_viable())
     self.assertTrue(calcs.pedi.is_risks_calc_viable())
     remaining_life = RemainingLifetimeRisk(calcs)
     p2 = remaining_life._get_pedi()
     self.assertEqual(len(p1.people), len(p2.people))
     self.assertEqual(p1.get_target().age, p2.get_target().age)
Ejemplo n.º 8
0
    def test_calculations2(self):
        """ Test prediction of cancer risk and mutation probability. """
        pedigree = deepcopy(self.pedigree)
        target = pedigree.get_target()
        target.age = str(int(target.age) + 43)
        # sister
        #         diagnoses = CancerDiagnoses(bc1=Cancer("20"), bc2=Cancer(), oc=Cancer(),
        #                                     prc=Cancer(), pac=Cancer())
        #         sister = Female("FAM1", "F01", "0011", target.fathid, target.mothid, age="22", yob=str(self.year-23),
        #                         cancers=Cancers(diagnoses=diagnoses))
        #         pedigree.people.append(sister)

        # parents
        mother = pedigree.get_person(target.mothid)
        mother.yob = str(self.year - 84)
        mother.age = "85"
        mother.cancers = Cancers(bc1=Cancer("52"),
                                 bc2=Cancer(),
                                 oc=Cancer(),
                                 prc=Cancer(),
                                 pac=Cancer())

        # maternal grandparents
        (_maternal_grandfather,
         maternal_grandmother) = pedigree.add_parents(mother)

        maternal_grandmother.age = "81"
        maternal_grandmother.yob = "1912"
        maternal_grandmother.dead = "1"
        maternal_grandmother.cancers = Cancers(bc1=Cancer("42"),
                                               bc2=Cancer(),
                                               oc=Cancer(),
                                               prc=Cancer(),
                                               pac=Cancer())

        PedigreeFile.validate(pedigree)
        calcs = Predictions(pedigree, cwd=self.cwd)

        # each gene should have a mutation probability plus a result for no mutations
        for mp in calcs.mutation_probabilties:
            key = list(mp.keys())[0]
            self.assertTrue(key in settings.BC_MODEL['GENES']
                            or key == "no mutation")
        self.assertEqual(len(calcs.mutation_probabilties),
                         len(settings.BC_MODEL['GENES']) + 1)

        # risks calculated at different ages:
        self.assertEqual(len(calcs.cancer_risks), 9)
        self.assertTrue([c.get('age') for c in calcs.cancer_risks] ==
                        [64, 65, 66, 67, 68, 70, 73, 75, 80])
Ejemplo n.º 9
0
    def test_lifetime_risk(self):
        """ Test lifetime risk calculation matches the risk to 80 for a 20 year old. """
        pedigree = deepcopy(self.pedigree)
        t = pedigree.get_target()
        t.age = '20'
        PedigreeFile.validate(pedigree)
        calcs = Predictions(pedigree, cwd=self.cwd)
        c80 = None
        for c in calcs.cancer_risks:
            if c.get('age') == 80:
                c80 = c

        self.assertEqual(calcs.lifetime_cancer_risk[0]['breast cancer risk']['decimal'],
                         c80['breast cancer risk']['decimal'])
        self.assertEqual(calcs.lifetime_cancer_risk[0]['ovarian cancer risk']['decimal'],
                         c80['ovarian cancer risk']['decimal'])
Ejemplo n.º 10
0
    def test_calculations(self):
        """ Test prediction of cancer risk and mutation probability. """
        pedigree = deepcopy(self.pedigree)
        PedigreeFile.validate(pedigree)
        calcs = Predictions(pedigree, cwd=self.cwd)

        # each gene should have a mutation probability plus a result for no mutations
        for mp in calcs.mutation_probabilties:
            key = list(mp.keys())[0]
            self.assertTrue(key in settings.BC_MODEL['GENES'] or key == "no mutation")
        self.assertEqual(len(calcs.mutation_probabilties), len(settings.BC_MODEL['GENES']) + 1)

        # risks calculated at 16 different ages:
        self.assertEqual(len(calcs.cancer_risks), 16)
        self.assertTrue([c.get('age') for c in calcs.cancer_risks] ==
                        [21, 22, 23, 24, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])
Ejemplo n.º 11
0
    def test_incidence_rates(self):
        """ Test prediction of cancer risk and mutation probability for different incidence rates. """
        pedigree = deepcopy(self.pedigree)
        PedigreeFile.validate(pedigree)
        target = pedigree.get_target()
        target.age = 78
        crates = settings.BC_MODEL['CANCER_RATES']

        for cancer_rates in crates.values():
            calcs = Predictions(pedigree, cwd=self.cwd, cancer_rates=cancer_rates)

            # each gene should have a mutation probability plus a result for no mutations
            self.assertEqual(len(calcs.mutation_probabilties), len(settings.BC_MODEL['GENES']) + 1)

            # risks calculated at different ages:
            self.assertTrue([c.get('age') for c in calcs.cancer_risks] ==
                            [79, 80])
Ejemplo n.º 12
0
 def run_calc(cls, can, pedigree, calcs=None, cwd=None):
     """ Run rrisk calculations """
     msettings = settings.BC_MODEL if can == 'breast' else settings.OC_MODEL
     mparams = ModelParams(
         mutation_frequency=msettings['MUTATION_FREQUENCIES']["UK"],
         mutation_sensitivity=msettings['GENETIC_TEST_SENSITIVITY'])
     calcs = Predictions(pedigree,
                         cwd=cwd,
                         model_settings=msettings,
                         model_params=mparams,
                         calcs=calcs)
     c80 = None
     for c in calcs.cancer_risks:
         if c.get('age') == 80:
             c80 = c
     return c80[can +
                ' cancer risk']['decimal'], calcs.lifetime_cancer_risk[0][
                    can + ' cancer risk']['decimal']
Ejemplo n.º 13
0
    def test_mutation_frequencies(self):
        """ Test prediction of cancer risk and mutation probability for different mutation frequencies. """
        pedigree = deepcopy(self.pedigree)
        PedigreeFile.validate(pedigree)
        target = pedigree.get_target()
        target.age = 78
        mutation_frequencies = settings.BC_MODEL['MUTATION_FREQUENCIES']

        for mf in mutation_frequencies.keys():
            if mf == 'Custom':
                continue
            params = ModelParams(mutation_frequency=mutation_frequencies[mf])
            calcs = Predictions(pedigree, cwd=self.cwd, model_params=params)

            # each gene should have a mutation probability plus a result for no mutations
            self.assertEqual(len(calcs.mutation_probabilties), len(settings.BC_MODEL['GENES']) + 1)

            # risks calculated at different ages:
            self.assertTrue([c.get('age') for c in calcs.cancer_risks] ==
                            [79, 80])
Ejemplo n.º 14
0
    def test_ovarian_calculations(self):
        """ Test prediction of cancer risk and mutation probability. """
        target = Female("FAM1",
                        "F0",
                        "001",
                        "002",
                        "003",
                        target="1",
                        age="20",
                        yob=str(self.year - 20),
                        cancers=Cancers(),
                        gtests=CanRiskGeneticTests.default_factory())
        pedigree = CanRiskPedigree(people=[target])
        # parents
        (_father, _mother) = pedigree.add_parents(
            target, gtests=CanRiskGeneticTests.default_factory())
        PedigreeFile.validate(pedigree)
        params = ModelParams(
            mutation_frequency=settings.OC_MODEL['MUTATION_FREQUENCIES']["UK"],
            mutation_sensitivity=settings.OC_MODEL['GENETIC_TEST_SENSITIVITY'])
        calcs = Predictions(pedigree,
                            cwd=self.cwd,
                            model_params=params,
                            model_settings=settings.OC_MODEL,
                            calcs=[])

        # each gene should have a mutation probability plus a result for no mutations
        for mp in calcs.mutation_probabilties:
            key = list(mp.keys())[0]
            self.assertTrue(key in settings.OC_MODEL['GENES']
                            or key == "no mutation")
        self.assertEqual(len(calcs.mutation_probabilties),
                         len(settings.OC_MODEL['GENES']) + 1)

        # risks calculated at 16 different ages:
        self.assertEqual(len(calcs.cancer_risks), 16)
        self.assertTrue(
            [c.get('age') for c in calcs.cancer_risks] ==
            [21, 22, 23, 24, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])
Ejemplo n.º 15
0
    def post_to_model(self, request, model_settings):
        serializer = self.serializer_class(data=request.data)
        if serializer.is_valid(raise_exception=True):
            validated_data = serializer.validated_data
            pedigree_data = validated_data.get('pedigree_data')
            pf = PedigreeFile(pedigree_data)
            population = validated_data.get('mut_freq', 'UK')
            cancer_rates = model_settings['CANCER_RATES'].get(
                validated_data.get('cancer_rates'))

            if population != 'Custom':
                mutation_frequency = model_settings['MUTATION_FREQUENCIES'][
                    population]
            else:
                mutation_frequency = {}
                for gene in model_settings['GENES']:
                    try:
                        mutation_frequency[gene] = float(
                            validated_data.get(gene.lower() +
                                               '_mut_frequency'))
                    except TypeError:
                        raise NotAcceptable("Invalid mutation frequency for " +
                                            gene + ".")

            gts = model_settings['GENETIC_TEST_SENSITIVITY']
            mutation_sensitivity = {
                k: float(
                    validated_data.get(k.lower() + "_mut_sensitivity", gts[k]))
                for k in gts.keys()
            }

            output = {
                "timestamp": datetime.datetime.now(),
                "mutation_frequency": {
                    population: mutation_frequency
                },
                "mutation_sensitivity": mutation_sensitivity,
                "cancer_incidence_rates": cancer_rates,
                "pedigree_result": []
            }

            if request.user.has_perm('boadicea_auth.can_risk'):
                risk_factor_code = validated_data.get('risk_factor_code', 0)
                prs = validated_data.get('prs', None)
                if prs is not None:
                    prs = Prs(prs.get('alpha'), prs.get('zscore'))
            else:
                if validated_data.get('risk_factor_code', 0) > 0:
                    logger.warning(
                        'risk factor code parameter provided without the correct permissions'
                    )
                if validated_data.get('prs', 0) != 0:
                    logger.warning(
                        'polygenic risk score parameter provided without the correct permissions'
                    )
                risk_factor_code = 0
                prs = None

            try:
                warnings = PedigreeFile.validate(pf.pedigrees)
                if len(warnings) > 0:
                    output['warnings'] = warnings
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST)

            # note limit username string length used here to avoid paths to long for model code
            cwd = tempfile.mkdtemp(prefix=str(request.user)[:20] + "_",
                                   dir=settings.CWD_DIR)
            try:
                for pedi in pf.pedigrees:
                    this_pedigree = {}
                    this_pedigree["family_id"] = pedi.famid
                    this_pedigree["proband_id"] = pedi.get_target().pid

                    this_mutation_frequency = mutation_frequency
                    this_population = population
                    # check if Ashkenazi Jewish status set & correct mutation frequencies
                    if pedi.is_ashkn():
                        if not REGEX_ASHKN.match(population):
                            msg = 'mutation frequencies set to Ashkenazi Jewish population values ' \
                                  'for family ('+pedi.famid+') as a family member has Ashkenazi Jewish status.'
                            logger.debug(
                                'mutation frequencies set to Ashkenazi Jewish population values'
                            )
                            if 'warnings' in output:
                                output['warnings'].append(msg)
                            else:
                                output['warnings'] = [msg]
                            this_population = 'Ashkenazi'
                            this_mutation_frequency = model_settings[
                                'MUTATION_FREQUENCIES'][this_population]

                    mname = model_settings['NAME']
                    if request.user.has_perm(
                            'boadicea_auth.can_risk') and isinstance(
                                pedi, CanRiskPedigree):
                        # for canrisk format files check if risk factors and/or prs set in the header
                        if 'risk_factor_code' not in request.data.keys():
                            risk_factor_code = pedi.get_rfcode(mname)

                        if prs is None or len(pf.pedigrees) > 1:
                            prs = pedi.get_prs(mname)

                    if request.user.has_perm('boadicea_auth.can_risk'):
                        # add risk factors and prs used for this pedigree
                        this_pedigree["risk_factors"] = self.get_risk_factors(
                            model_settings, risk_factor_code)
                        logger.debug(mname + ' risk factor code ' +
                                     str(risk_factor_code))
                        if prs is not None:
                            this_pedigree["prs"] = {
                                'alpha': prs.alpha,
                                'zscore': prs.zscore
                            }
                            logger.debug(mname + ' PRS alpha:' +
                                         str(this_pedigree["prs"]))

                    calcs = Predictions(
                        pedi,
                        mutation_frequency=this_mutation_frequency,
                        mutation_sensitivity=mutation_sensitivity,
                        cancer_rates=cancer_rates,
                        risk_factor_code=risk_factor_code,
                        prs=prs,
                        cwd=cwd,
                        request=request,
                        model_settings=model_settings)
                    # Add input parameters and calculated results as attributes to 'this_pedigree'
                    this_pedigree["mutation_frequency"] = {
                        this_population: this_mutation_frequency
                    }
                    self.add_attr("version", output, calcs, output)
                    self.add_attr("mutation_probabilties", this_pedigree,
                                  calcs, output)
                    self.add_attr("cancer_risks", this_pedigree, calcs, output)
                    self.add_attr("baseline_cancer_risks", this_pedigree,
                                  calcs, output)
                    self.add_attr("lifetime_cancer_risk", this_pedigree, calcs,
                                  output)
                    self.add_attr("baseline_lifetime_cancer_risk",
                                  this_pedigree, calcs, output)
                    self.add_attr("ten_yr_cancer_risk", this_pedigree, calcs,
                                  output)
                    self.add_attr("baseline_ten_yr_cancer_risk", this_pedigree,
                                  calcs, output)

                    output["pedigree_result"].append(this_pedigree)
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST,
                                    safe=False)
            finally:
                if (not request.user.has_perm('boadicea_auth.evaluation') and
                        not request.user.has_perm('boadicea_auth.evaluation1b')
                    ):
                    shutil.rmtree(cwd)
            output_serialiser = OutputSerializer(output)
            return Response(output_serialiser.data,
                            template_name='result_tab_gp.html')

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 16
0
    def post(self, request):
        serializer = self.serializer_class(data=request.data)
        if serializer.is_valid(raise_exception=True):
            validated_data = serializer.validated_data
            pf = PedigreeFile(validated_data.get('pedigree_data'))
            model_settings = settings.BC_MODEL
            params = ModelParams.factory(validated_data, model_settings)

            tenyr_ages = re.sub("[\[\]]", "", validated_data.get('tenyr_ages'))
            tenyr_ages = [int(item.strip()) for item in tenyr_ages.split(',')]
            logger.debug(tenyr_ages)

            output = {
                "timestamp": datetime.datetime.now(),
                "mutation_frequency": {
                    params.population: params.mutation_frequency
                },
                "mutation_sensitivity": params.mutation_sensitivity,
                "cancer_incidence_rates": params.cancer_rates,
                "pedigree_result": []
            }

            risk_factor_code = validated_data.get('risk_factor_code', 0)
            prs = validated_data.get('prs', None)
            if prs is not None:
                prs = Prs(prs.get('alpha'), prs.get('zscore'))

            try:
                warnings = PedigreeFile.validate(pf.pedigrees)
                if len(warnings) > 0:
                    output['warnings'] = warnings
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST)

            # note limit username string length used here to avoid paths too long for model code
            cwd = tempfile.mkdtemp(prefix=str(request.user)[:20] + "_",
                                   dir=settings.CWD_DIR)
            try:
                for pedi in pf.pedigrees:
                    this_params = deepcopy(params)
                    # check if Ashkenazi Jewish status set & correct mutation frequencies
                    if pedi.is_ashkn() and not REGEX_ASHKN.match(
                            params.population):
                        msg = 'mutation frequencies set to Ashkenazi Jewish population values ' \
                              'for family ('+pedi.famid+') as a family member has Ashkenazi Jewish status.'
                        logger.debug(
                            'mutation frequencies set to Ashkenazi Jewish population values'
                        )
                        if 'warnings' in output:
                            output['warnings'].append(msg)
                        else:
                            output['warnings'] = [msg]
                        this_params.population = 'Ashkenazi'
                        this_params.mutation_frequency = model_settings[
                            'MUTATION_FREQUENCIES']['Ashkenazi']

                    if isinstance(pedi, CanRiskPedigree):
                        # for canrisk format files check if risk factors and/or prs set in the header
                        mname = model_settings['NAME']
                        if 'risk_factor_code' not in request.data.keys():
                            risk_factor_code = pedi.get_rfcode(mname)

                        if prs is None or len(pf.pedigrees) > 1:
                            prs = pedi.get_prs(mname)

                    calcs = Predictions(pedi,
                                        model_params=this_params,
                                        risk_factor_code=risk_factor_code,
                                        prs=prs,
                                        run_risks=False,
                                        cwd=cwd,
                                        request=request,
                                        model_settings=model_settings)
                    calcs.niceness = Predictions._get_niceness(calcs.pedi)

                    calcs.ten_yr_cancer_risk = []
                    for tenyr in tenyr_ages:
                        ten_yr_risk, _v = RangeRisk(calcs, int(tenyr),
                                                    int(tenyr + 10),
                                                    "10 YR RANGE").get_risk()
                        if ten_yr_risk is not None:
                            calcs.ten_yr_cancer_risk.append(ten_yr_risk[0])

                    # Add input parameters and calculated results as attributes to 'this_pedigree'
                    this_pedigree = {}
                    this_pedigree["family_id"] = pedi.famid
                    this_pedigree["proband_id"] = pedi.get_target().pid
                    this_pedigree["risk_factors"] = self.get_risk_factors(
                        model_settings, risk_factor_code)
                    if prs is not None:
                        this_pedigree["prs"] = {
                            'alpha': prs.alpha,
                            'zscore': prs.zscore
                        }
                    this_pedigree["mutation_frequency"] = {
                        this_params.population: this_params.mutation_frequency
                    }
                    self.add_attr("version", output, calcs, output)
                    self.add_attr("ten_yr_cancer_risk", this_pedigree, calcs,
                                  output)

                    output["pedigree_result"].append(this_pedigree)
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST,
                                    safe=False)
            finally:
                shutil.rmtree(cwd)
            output_serialiser = OutputSerializer(output)
            return Response(output_serialiser.data,
                            template_name='result_tab_gp.html')

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 17
0
    def post_to_model(self, request, model_settings):
        serializer = self.serializer_class(data=request.data)
        if serializer.is_valid(raise_exception=True):
            validated_data = serializer.validated_data
            pf = PedigreeFile(validated_data.get('pedigree_data'))
            params = ModelParams.factory(validated_data, model_settings)

            output = {
                "timestamp": datetime.datetime.now(),
                "mutation_frequency": {
                    params.population: params.mutation_frequency
                },
                "mutation_sensitivity": params.mutation_sensitivity,
                "cancer_incidence_rates": params.cancer_rates,
                "pedigree_result": []
            }

            prs = validated_data.get('prs', None)
            if prs is not None:
                prs = Prs(prs.get('alpha'), prs.get('zscore'))

            try:
                warnings = PedigreeFile.validate(pf.pedigrees)
                if len(warnings) > 0:
                    output['warnings'] = warnings
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST)

            # note limit username string length used here to avoid paths too long for model code
            cwd = tempfile.mkdtemp(prefix=str(request.user)[:20] + "_",
                                   dir=settings.CWD_DIR)
            try:
                for pedi in pf.pedigrees:
                    risk_factor_code = 0
                    this_params = deepcopy(params)
                    # check if Ashkenazi Jewish status set & correct mutation frequencies
                    if pedi.is_ashkn() and not settings.REGEX_ASHKN.match(
                            params.population):
                        msg = 'mutation frequencies set to Ashkenazi Jewish population values ' \
                              'for family ('+pedi.famid+') as a family member has Ashkenazi Jewish status.'
                        logger.debug(
                            'mutation frequencies set to Ashkenazi Jewish population values'
                        )
                        if 'warnings' in output:
                            output['warnings'].append(msg)
                        else:
                            output['warnings'] = [msg]
                        this_params.isashk = True
                        this_params.population = 'Ashkenazi'
                        this_params.mutation_frequency = model_settings[
                            'MUTATION_FREQUENCIES']['Ashkenazi']

                    if isinstance(pedi, CanRiskPedigree):
                        # for canrisk format files check if risk factors and/or prs set in the header
                        mname = model_settings['NAME']
                        risk_factor_code = pedi.get_rfcode(mname)

                        if prs is None or len(pf.pedigrees) > 1:
                            prs = pedi.get_prs(mname)

                    this_hgt = (pedi.hgt if hasattr(pedi, 'hgt') else -1)
                    calcs = Predictions(pedi,
                                        model_params=this_params,
                                        risk_factor_code=risk_factor_code,
                                        hgt=this_hgt,
                                        prs=prs,
                                        cwd=cwd,
                                        request=request,
                                        model_settings=model_settings)
                    # Add input parameters and calculated results as attributes to 'this_pedigree'
                    this_pedigree = {}
                    this_pedigree["family_id"] = pedi.famid
                    this_pedigree["proband_id"] = pedi.get_target().pid
                    this_pedigree["risk_factors"] = self.get_risk_factors(
                        model_settings, risk_factor_code)
                    this_pedigree["risk_factors"][_(
                        'Height (cm)')] = this_hgt if this_hgt != -1 else "-"
                    if prs is not None:
                        this_pedigree["prs"] = {
                            'alpha': prs.alpha,
                            'zscore': prs.zscore
                        }
                    this_pedigree["mutation_frequency"] = {
                        this_params.population: this_params.mutation_frequency
                    }
                    self.add_attr("version", output, calcs, output)
                    self.add_attr("mutation_probabilties", this_pedigree,
                                  calcs, output)
                    self.add_attr("cancer_risks", this_pedigree, calcs, output)
                    self.add_attr("baseline_cancer_risks", this_pedigree,
                                  calcs, output)
                    self.add_attr("lifetime_cancer_risk", this_pedigree, calcs,
                                  output)
                    self.add_attr("baseline_lifetime_cancer_risk",
                                  this_pedigree, calcs, output)
                    self.add_attr("ten_yr_cancer_risk", this_pedigree, calcs,
                                  output)
                    self.add_attr("baseline_ten_yr_cancer_risk", this_pedigree,
                                  calcs, output)

                    output["pedigree_result"].append(this_pedigree)
            except ValidationError as e:
                logger.error(e)
                return JsonResponse(e.detail,
                                    content_type="application/json",
                                    status=status.HTTP_400_BAD_REQUEST,
                                    safe=False)
            finally:
                shutil.rmtree(cwd)
                # print(model_settings['NAME']+" :: "+cwd)
            output_serialiser = OutputSerializer(output)
            return Response(output_serialiser.data,
                            template_name='result_tab_gp.html')

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)