def view_protein(uuid, protein_id):
    hypothesis = get_glycopeptide_hypothesis(uuid)
    session = object_session(hypothesis)
    protein = session.query(Protein).get(protein_id)
    response = render_template("view_glycopeptide_hypothesis/components/protein_view.templ", protein=protein)
    session.close()
    return response
def handle_glycopeptide_hypothesis(hypothesis):
    session = object_session(hypothesis)
    protein_table = protein_index(session, hypothesis.id)
    response = render_template("view_glycopeptide_hypothesis/container.templ",
                               hypothesis=hypothesis, protein_table=protein_table)
    session.close()
    return response
Esempio n. 3
0
    def save_solutions(self, identified_glycopeptides, unassigned_chromatograms,
                       chromatogram_extractor, database):
        if self.analysis_name is None:
            return
        self.log("Saving Results To \"%s\"" % (self.output_path,))
        exporter = self.make_analysis_serializer(
            self.output_path,
            self.analysis_name,
            chromatogram_extractor.peak_loader.sample_run,
            identified_glycopeptides,
            unassigned_chromatograms,
            database,
            chromatogram_extractor)

        exporter.run()

        exporter.set_parameters(
            self._build_analysis_saved_parameters(
                identified_glycopeptides, unassigned_chromatograms,
                chromatogram_extractor, database))

        self.analysis = exporter.analysis
        self.analysis_id = exporter.analysis.id
        for path in self.file_manager.dir():
            self.analysis.add_file(path, compress=True)

        session = object_session(self.analysis)
        session.add(self.analysis)
        session.commit()
def paginate_theoretical_glycopeptides(uuid, protein_id, page, per_page=50):
    hypothesis = get_glycopeptide_hypothesis(uuid)
    session = object_session(hypothesis)
    paginator = paginate(session.query(Glycopeptide).filter(
        Glycopeptide.protein_id == protein_id), page, per_page)
    base_index = (page - 1) * per_page
    response = render_template(
        "view_glycopeptide_hypothesis/components/display_table.templ",
        paginator=paginator, base_index=base_index)
    session.close()
    return response
def search_glycan_hypothesis(uuid, mass, ppm_tolerance):
    hypothesis = get_glycan_hypothesis(uuid)
    session = object_session(hypothesis)
    lo = mass - (mass * ppm_tolerance)
    hi = mass + (mass * ppm_tolerance)
    hits = session.query(GlycanComposition).filter(
        GlycanComposition.hypothesis_id == hypothesis.id,
        GlycanComposition.calculated_mass.between(lo, hi)).all()
    converted = [
        {"string": hit.composition, "mass": hit.calculated_mass,
         "error": (mass - hit.calculated_mass) / hit.calculated_mass} for hit in hits
    ]
    session.close()
    if len(converted) == 1:
        return jsonify(converted)
    else:
        return jsonify(*converted)
def view_glycan_composition_hypothesis_table(uuid, page=1):
    page_size = 50
    hypothesis = get_glycan_hypothesis(uuid)
    hypothesis_id = hypothesis.id

    def filter_context(q):
        return q.filter_by(
            hypothesis_id=hypothesis_id)
    session = object_session(hypothesis)
    paginator = paginate(filter_context(
        session.query(GlycanComposition).filter(
            GlycanComposition.hypothesis_id == hypothesis_id).order_by(
                GlycanComposition.calculated_mass)
        ), page, page_size)
    response = render_template(
        "view_glycan_hypothesis/display_table.templ",
        paginator=paginator, base_index=(page - 1) * page_size)
    session.close()
    return response
def view_glycan_composition_hypothesis(uuid):
    hypothesis = get_glycan_hypothesis(uuid)
    response = render_template("view_glycan_hypothesis/container.templ", hypothesis=hypothesis)
    object_session(hypothesis).close()
    return response
def handle_glycan_hypothesis(hypothesis):
    response = render_template("view_glycan_hypothesis/container.templ", hypothesis=hypothesis)
    object_session(hypothesis).close()
    return response