コード例 #1
0
ファイル: ui.py プロジェクト: xflicsu/immuno
def run_pipeline(patient_id, score_epitopes):
    """Run the pipeline for this patient, and save the output to the DB as a
    Run."""
    hla_types = HLAType.query.with_entities(HLAType.allele,
        HLAType.mhc_class).filter_by(patient_id=patient_id).all()

    peptide_length = 31
    alleles = [normalize_hla_allele_name(
        allele) for allele, mhc_class in hla_types]

    vcf_df = get_vcf_df(patient_id)
    transcripts_df, vcf_df, variant_report = expand_transcripts(
        vcf_df,
        patient_id,
        min_peptide_length = peptide_length,
        max_peptide_length = peptide_length)

    scored_epitopes = score_epitopes(transcripts_df, alleles)
    imm = ImmunogenicityPredictor(alleles=alleles)
    scored_epitopes = imm.predict(scored_epitopes)

    # TODO(tavi) Make this expansion more robust. It breaks the IEDB predictor,
    # for example.
    short_transcripts_df = transcripts_df[['chr', 'pos', 'ref',
        'alt', 'TranscriptId']]
    scored_epitopes = merge(scored_epitopes, short_transcripts_df,
        on='TranscriptId', how='left')
    peptides = group_epitopes_dataframe(
        scored_epitopes, use_transcript_name = True)

    run = Run(patient_id=patient_id, output=dumps(peptides))
    db.session.add(run)
コード例 #2
0
ファイル: mutation_report.py プロジェクト: hammerlab/immuno
    scored_epitopes = mhc_binding_prediction(mutated_regions, alleles)

    if args.skip_thymic_deletion:
        scored_epitopes[THYMIC_DELETION_FIELD_NAME] = False
    else:
        imm = ImmunogenicityPredictor(alleles = alleles)
        scored_epitopes = imm.predict(scored_epitopes)

    if PERCENTILE_RANK_FIELD_NAME in scored_epitopes:
        scored_epitopes = scored_epitopes.sort([PERCENTILE_RANK_FIELD_NAME])

    if args.output_epitopes_file:
        scored_epitopes.to_csv(args.output_epitopes_file, index=False)


    source_sequences = group_epitopes_dataframe(scored_epitopes)

    if args.print_epitopes:
        print_epitopes(source_sequences)

    if args.print_vaccine_peptides or args.vaccine_peptide_file:
        padding = args.vaccine_peptide_padding
        if args.vaccine_peptide_logistic_epitope_scoring:
            epitope_scorer = logistic_ic50_epitope_scorer
        else:
            epitope_scorer = simple_ic50_epitope_scorer

        vaccine_peptide_records = select_vaccine_peptides(
            source_sequences,
            epitope_scorer=epitope_scorer,
            vaccine_peptide_length=peptide_length,