Exemplo n.º 1
0
//  ----------------------------------------------------------------------------
bool
CVcfReader::xAssignVariationAlleles(
    const CVcfData& data,
    unsigned int index,
    CRef<CSeq_feat> pFeature )
//  ----------------------------------------------------------------------------
{
    if (data.IsSnv(index)) {
        return xAssignVariantSnv(data, index, pFeature);
    }
    if (data.IsDel(index)) {
        return xAssignVariantDel(data, index, pFeature);
    }
    if (data.IsIns(index)) {
        return xAssignVariantIns(data, index, pFeature);
    }
    if (data.IsDelins(index)) {
        return xAssignVariantDelins(data, index, pFeature);
    }
    CVariation_ref::TData::TSet::TVariations& variants =
        pFeature->SetData().SetVariation().SetData().SetSet().SetVariations();
    CRef<CVariation_ref> pVariant(new CVariation_ref);
    string note("Warning: Could not place variation for record \"" + 
        NStr::Replace(data.m_strLine.substr(0, 40), "\t", "  "));
    if (data.m_strLine.size() > 40) {
        note += "...";
    }
    note += "\". Offending values: ref=\"" + data.m_strRef + 
        "\", alt=\"" + data.m_Alt[index] + "\"";
    pVariant->SetData().SetNote(note);
    variants.push_back(pVariant);
    return true;
}
Exemplo n.º 2
0
//  ----------------------------------------------------------------------------
bool
CVcfReader::xAssignVariationAlleleSet(
    const CVcfData& data,
    CRef<CSeq_feat> pFeature )
//  ----------------------------------------------------------------------------
{
    CVariation_ref::TData::TSet::TVariations& variants =
        pFeature->SetData().SetVariation().SetData().SetSet().SetVariations();

    //make one variation for the reference
    CRef<CVariation_ref> pIdentity(new CVariation_ref);
    vector<string> variant;
 
    switch(data.m_SetType) {
    case CVcfData::ST_ALL_INS:
        pIdentity->SetDeletion();
        break;
    default: 
        variant.push_back(data.m_strRef);
        pIdentity->SetSNV(variant, CVariation_ref::eSeqType_na);
        break;
    }
    CVariation_inst& instance = pIdentity->SetData().SetInstance();
    instance.SetType(CVariation_inst::eType_identity);
    instance.SetObservation(CVariation_inst::eObservation_reference);
    if (data.m_SetType != CVcfData::ST_ALL_INS) {
        variants.push_back(pIdentity);
    }

    //add additional variations, one for each alternative
    for (unsigned int i=0; i < data.m_Alt.size(); ++i) {
        switch(data.m_SetType) {
        default:
            if (!xAssignVariantDelins(data, i, pFeature)) {
                return false;
            }
            break;
        case CVcfData::ST_ALL_SNV:
            if (!xAssignVariantSnv(data, i, pFeature)) {
                return false;
            }
            break;
        case CVcfData::ST_ALL_MNV:
            if (!xAssignVariantMnv(data, i, pFeature)) {
                return false;
            }
            break;
        case CVcfData::ST_ALL_INS:
            if (!xAssignVariantIns(data, i, pFeature)) {
                return false;
            }
            break;
        case CVcfData::ST_ALL_DEL:
            if (!xAssignVariantDel(data, i, pFeature)) {
                return false;
            }
            break;
        }
    }
    return true;
}