def validateSolution(self, solution):
        '''
        Solution validation tests
        '''
        if solution.sequence == None or ('?' in solution.levels.values()):
            sys.stderr.write("SolutionValidator: Level unknown - " +
                             str(solution.levels) + "\n")
            solution.valid = False
            return 0

        # Basic validation
        designed_region = solution.sequence
        valid = validateCDS(designed_region)

        # # No internal Promoters - e coli specific
        # (score, _, _) = Functions.look_for_promoters(designed_region)
        # if score >= 15.3990166: #0.95 percentile for Promoter PWM scores
        #     valid = False
        #     sys.stderr.write("SolutionValidator: High Promoter score: "+str(score)+"\n")

        # # No internal Terminator - only for bacterial genomes?
        # score = Functions.look_for_terminators(seq=designed_region, outdir=self.root_dir)
        # if score >= 90: #90% confidence from transtermHP
        #     valid = False
        #     sys.stderr.write("SolutionValidator: High Terminator score\n")

        # # No restriction enzymes
        # if 'ggtctc' in designed_region or 'gagacc' in designed_region:
        #    sys.stderr.write("SolutionValidator: Restriction enzyme found\n")
        #    valid = False

        solution.valid = valid

        return valid
    def configureSolution(self, solution):
        solution.valid = validateCDS(solution.sequence[49:])

        if solution.valid:
            #CAI
            cai_obj = CAI.CAI(solution=solution,
                              label="cds",
                              args={'cai_range': (49, len(solution.sequence))})

            #Look for RBS
            dup_obj1 = RNADuplexRNAFold.RNADuplexRNAFoldRibosome(
                solution1=solution,
                label="sd16s",
                args={'rnaMolecule1region': (25, 48)})
            dup_mfe = RNADuplexRNAFold.RNADuplexRNAFoldMFE(dup_obj1)
            dup_obj1.add_subfeature(dup_mfe)

            #MFE [-30,30]
            st1_obj = StructureRNAFold.StructureRNAFold(
                solution=solution,
                label="utr",
                args={'structure_range': (49 - 30, 49 + 30)})
            st_mfe = StructureRNAFold.StructureRNAFoldMFE(st1_obj)
            st1_obj.add_subfeature(st_mfe)

            solution.add_feature(cai_obj)
            solution.add_feature(dup_obj1)
            solution.add_feature(st1_obj)
Esempio n. 3
0
    def configureSolution(self, solution):

        try:
            solution.valid = validateCDS(
                solution.sequence,
                check_frame=self.check_frame,
                check_start=self.check_start,
                check_end_stop=self.check_end_stop,
                check_within_stop=self.check_within_stop)
        except DTailorException:
            logger.error('Solution invalid')
            solution.valid = False

        if solution.valid:

            if self.ramp:
                # CAI - entire sequence
                cai_all_obj = CAI(solution=solution,
                                  label="all",
                                  cai_table=self.cai_table,
                                  args={
                                      'cai_range': (0, len(solution.sequence)),
                                      'mutable_region':
                                      range(0, len(solution.sequence))
                                  })
                solution.add_feature(cai_all_obj)

                # CAI - ramp only
                cai_ramp_obj = CAI(solution=solution,
                                   label="ramp",
                                   cai_table=self.cai_table,
                                   args={
                                       'cai_range': (0, self.ramp_from_to[1]),
                                       'mutable_region':
                                       range(0, self.ramp_from_to[1])
                                   })
                solution.add_feature(cai_ramp_obj)

                # CAI - not ramp only
                # If sequence is too short just redo the CAI calc
                if len(solution.sequence) <= self.ramp_from_to[1]:
                    cai_rest_obj = CAI(solution=solution,
                                       label="rest",
                                       cai_table=self.cai_table,
                                       args={
                                           'cai_range':
                                           (0, self.ramp_from_to[1]),
                                           'mutable_region':
                                           range(0, self.ramp_from_to[1])
                                       })
                else:
                    cai_rest_obj = CAI(solution=solution,
                                       label="rest",
                                       cai_table=self.cai_table,
                                       args={
                                           'cai_range':
                                           (self.ramp_from_to[1],
                                            len(solution.sequence)),
                                           'mutable_region':
                                           range(self.ramp_from_to[1],
                                                 len(solution.sequence))
                                       })
                solution.add_feature(cai_rest_obj)

                # MFE - ramp only
                st1_obj = StructureRNAFold(solution=solution,
                                           label="mfe",
                                           args={
                                               'structure_range':
                                               (self.ramp_from_to[0],
                                                self.ramp_from_to[1]),
                                               'mutable_region':
                                               range(self.ramp_from_to[0],
                                                     self.ramp_from_to[1])
                                           })
                st_mfe = StructureRNAFoldMFE(structureObject=st1_obj)
                st1_obj.add_subfeature(st_mfe)
                solution.add_feature(st1_obj)
            else:
                # CAI - entire sequence
                cai_all_obj = CAI(solution=solution,
                                  label="all",
                                  cai_table=self.cai_table,
                                  args={
                                      'cai_range': (0, len(solution.sequence)),
                                      'mutable_region':
                                      range(0, len(solution.sequence))
                                  })
                solution.add_feature(cai_all_obj)