AlleleAttributes alleleAttributes(Allele & main_allele, Allele & reference_allele) { assert(!(main_allele.seq().empty())); assert(!(reference_allele.seq().empty())); assert(!(reference_allele.isMissing())); if (main_allele.isMissing()) { return AlleleAttributes(Type::Missing, 0, 0, 0); } if (main_allele == reference_allele) { return AlleleAttributes(Type::Reference, main_allele.seq().size(), count(main_allele.seq().begin(), main_allele.seq().end(), 'N'), 0); } Allele trimmed_main_allele = main_allele; Allele trimmed_reference_allele = reference_allele; fullTrimAllelePair(&trimmed_main_allele, &trimmed_reference_allele); assert(!(trimmed_main_allele.seq().empty()) or !(trimmed_reference_allele.seq().empty())); uint trimmed_main_allele_length = trimmed_main_allele.seq().size(); uint trimmed_reference_allele_length = trimmed_reference_allele.seq().size(); uint trimmed_main_allele_num_ambiguous = count(trimmed_main_allele.seq().begin(), trimmed_main_allele.seq().end(), 'N'); if (trimmed_main_allele_length == trimmed_reference_allele_length) { auto allele_type = Type::Complex; if (trimmed_main_allele_length == 1) { allele_type = Type::SNP; } else if (isInversion(trimmed_main_allele, trimmed_reference_allele, 0.95, 10)) { allele_type = Type::Inversion; } return AlleleAttributes(allele_type, trimmed_main_allele_length, trimmed_main_allele_num_ambiguous, 0); } else { auto allele_type = Type::Complex; if (trimmed_main_allele_length == 0) { allele_type = Type::Deletion; } else if (trimmed_reference_allele_length == 0) { allele_type = Type::Insertion; } return AlleleAttributes(allele_type, trimmed_main_allele_length, trimmed_main_allele_num_ambiguous, trimmed_main_allele_length - trimmed_reference_allele_length); } }
string getAlleleStringAttribute(Allele & allele, const string attribute) { auto att_value = allele.info().getValue<string>(attribute); if (att_value.second) { if (att_value.first == ".") { return "NoValue"; } else { assert(!(allele.isMissing())); return att_value.first; } } else { return "Reference"; } }