示例#1
0
    def process_primer(self):
        source = UCSCSequenceSource()
        left_padding = 1000
        right_padding = 1000
        sequences = source.sequences_for_primers(
            self.form_result["primer_fwd"], self.form_result["primer_rev"], left_padding, right_padding
        )

        # TODO: better selective update method
        c.primer_fwd = self.form_result["primer_fwd"]
        c.primer_rev = self.form_result["primer_rev"]
        c.left_padding = left_padding
        c.right_padding = right_padding
        c.sequences = sequences

        for seq in c.sequences:
            seq.snps = self._get_snps(seq.chromosome, seq.start, seq.end)
            self.__add_sequence_primer_display_attrs(
                seq, primer_fwd=self.form_result["primer_fwd"], primer_rev=self.form_result["primer_rev"]
            )

        assayutil.set_amplicon_snps(c.sequences)

        c.assay_form = h.LiteralForm(
            value={"primer_fwd": self.form_result["primer_fwd"], "primer_rev": self.form_result["primer_rev"]}
        )

        return render("/assay/primer_output.html")
示例#2
0
    def process_location(self):
        source = UCSCSequenceSource()
        left_padding = 1000
        right_padding = 1000
        sequence = source.sequence_around_loc(
            self.form_result["chromosome"],
            self.form_result["location"],
            self.form_result["width"],
            left_padding,
            right_padding,
        )
        # TODO: better selective update method
        c.chromosome = self.form_result["chromosome"]
        c.location = self.form_result["location"]
        c.width = self.form_result["width"]
        c.left_padding = left_padding
        c.right_padding = right_padding
        c.sequence = sequence
        c.sequences = [sequence]

        for seq in c.sequences:
            seq.snps = self._get_snps(seq.chromosome, seq.start, seq.end)
            seq.positive_display_sequence = seq.amplicon.positive_strand_sequence.lower()
            seq.negative_display_sequence = seq.amplicon.negative_strand_sequence.lower()

        assayutil.set_amplicon_snps(c.sequences)

        c.assay_form = h.LiteralForm()
        return render("/assay/location_output.html")
示例#3
0
    def process_snp(self):
        snp_source = HG19Source()
        seq_source = UCSCSequenceSource()
        left_padding = 1000
        right_padding = 1000
        snps = snp_source.snps_by_rsid(self.form_result["snp_rsid"])

        c.assay_form = h.LiteralForm()

        c.snp_rsid = self.form_result["snp_rsid"]
        c.width = self.form_result["width"]

        # override
        if not snps or len(snps) == 0:
            # TODO: figure out how to make this appear on the field error instead
            session["flash"] = "Could not find a SNP with the name %s" % self.form_result["snp_rsid"]
            session["flash_class"] = "error"
            session.save()
            return render("/assay/snp_output.html")

        sequences = []
        for snp in snps:
            chromStart = snp["chromStart"]
            chromEnd = snp["chromEnd"]

            # handle insertions and single variations, normally the chromStart
            # refers to the gap just before the base #
            if snp["chromStart"] == snp["chromEnd"]:
                chromStart = chromEnd
            else:
                chromStart += 1

            sequence = seq_source.sequence_around_region(
                snp["chrom"][3:], chromStart, chromEnd, self.form_result["width"], left_padding, right_padding
            )
            # sequence.snps = self._get_snps(sequence.chromosome, sequence.start, sequence.end)
            sequences.append(sequence)

        c.left_padding = left_padding
        c.right_padding = right_padding
        c.sequences = sequences
        for seq in c.sequences:
            seq.snps = self._get_snps(seq.chromosome, seq.start, seq.end)
            seq.positive_display_sequence = seq.amplicon.positive_strand_sequence.lower()
            seq.negative_display_sequence = seq.amplicon.negative_strand_sequence.lower()[::-1]

        assayutil.set_amplicon_snps(c.sequences)

        return render("/assay/snp_output.html")
示例#4
0
    def view(self, id):
        sequences = []
        assay = Session.query(Assay).filter_by(id=id).first()
        if not assay:
            abort(404)

        seq_source = UCSCSequenceSource()
        snp_source = HG19Source()
        sequences = assayutil.sequences_snps_for_assay(config, assay, seq_source, snp_source, 1000, 1000)

        c.sequences = [tm_pcr_sequence(config, dg_pcr_sequence(config, seq)) for seq in sequences]
        assayutil.set_amplicon_snps(c.sequences)

        if assay.assay_type == Assay.TYPE_PRIMER:
            for seq in c.sequences:
                self.__add_sequence_primer_display_attrs(seq, assay=assay)
        else:
            for seq in c.sequences:
                seq.positive_display_sequence = seq.amplicon.positive_strand_sequence.lower()
                seq.negative_display_sequence = seq.amplicon.negative_strand_sequence.lower()[::-1]

        c.assay = assay
        c.hide_save = True
        return render("/assay/view.html")