Skip to content

Commit

Permalink
accept phased GT
Browse files Browse the repository at this point in the history
  • Loading branch information
arangrhie committed Jun 24, 2021
1 parent dae0d7d commit bc5fd39
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/merfin/merfin-globals.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ merfinGlobal::load_Kmetric(void) {
char *line = nullptr;

while (AS_UTL_readLine(line, lineLen, lineMax, F.file())) {
splitToWords S(line, splitLetter, ',');
splitToWords S(line, ',');

if (S.numWords() == 2) {
uint32 k = S.touint32(0);
Expand Down
21 changes: 10 additions & 11 deletions src/merfin/merfin-variants.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ traverse(uint32 idx,
replaced = candidate;
replaced.replace(refIdxList[idx], refLenList[idx], hap);

//fprintf(stderr, "REPLACE candidate '%s' ->\n", candidate.c_str());
//fprintf(stderr, "REPLACE replaced '%s' by change %u-%u to '%s'\n", replaced.c_str(), refIdxList[idx], refLenList[idx], hap);
// Debug traversed variant we are testing
// fprintf(stderr, "REPLACE candidate '%s' ->\n", candidate.c_str());
// fprintf(stderr, "REPLACE replaced '%s' by change %u-%u to '%s'\n", replaced.c_str(), refIdxList[idx], refLenList[idx], hap);

// Apply to the rest of the positions, after skipping overlaps
// refIdx in overlaps should remain as they were as we are using ref allele at these sites anyway
Expand Down Expand Up @@ -181,12 +182,12 @@ processVariants(void *G, void *T, void *S) {

// Debug report the mapPosHap

//fprintf(stderr, "\n");
//fprintf(stderr, "[ DEBUG ] :: %s : %u - %u\n", s->seq.ident(), rStart, rEnd);
//fprintf(stderr, "[ DEBUG ] :: gts.size = %lu | ", gts.size());
//for (uint32 i = 0; i < gts.size(); i++)
// fprintf(stderr, "gt->_pos = %u ", gts[i]->_pos);
//fprintf(stderr, "\n");
// fprintf(stderr, "\n");
// fprintf(stderr, "[ DEBUG ] :: %s : %u - %u\n", s->seq.ident(), rStart, rEnd);
// fprintf(stderr, "[ DEBUG ] :: gts.size = %lu | ", gts.size());
// for (uint32 i = 0; i < gts.size(); i++)
// fprintf(stderr, "gt->_pos = %u ", gts[i]->_pos);
// fprintf(stderr, "\n");

// Load mapPosHap

Expand All @@ -197,7 +198,6 @@ processVariants(void *G, void *T, void *S) {
refLenList.push_back(gt->_refLen);

// add alleles. alleles[0] is always the ref allele
#warning is this copying the whole vector?
mapPosHap[i] = gt->_alleles;
}

Expand All @@ -216,7 +216,7 @@ processVariants(void *G, void *T, void *S) {
continue;
}

//fprintf(stderr, "%s\n", refTemplate);
// fprintf(stderr, "%s\n", refTemplate);

//

Expand Down Expand Up @@ -250,7 +250,6 @@ processVariants(void *G, void *T, void *S) {
seqMer->getMaxAbsK(idx),
seqMer->getMedAbsK(idx),
seqMer->getAvgAbsK(idx),
//seqMer->getAvgAbsdK(idx, RefAvgK),
seqMer->getTotdK(idx));

// new vcf records
Expand Down
8 changes: 7 additions & 1 deletion src/merfin/vcf.C
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ gtAllele::gtAllele(vcfRecord *r) {
return;
}

splitToWords GT(_record->_arr_samples[0], splitLetter, '/');
// Make this accept both '/' and '|' as delimiters

splitToWords GT;
GT.split(_record->_arr_samples[0], "|/");

_alleles.push_back(_record->get_ref()); // _alleles[0] is ALWAYS the reference allele.

// Add alternate alleles to the list, as long as they aren't already there.

for (uint32 ii=0; ii<GT.numWords(); ii++) {
// DEBUG :: print the GTs
// fprintf(stderr, "[ DEBUG ] :: GT[%d]=%s\n", ii, GT[ii]);

int32 altIdx = strtoint32(GT[ii]);

if (altIdx <= 0) { // This handles the case of gt being the empty string,
Expand Down
10 changes: 5 additions & 5 deletions src/merfin/vcfRecord.H
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public:
// DP - read depth
//
bool load(char *inLine) {
_words.split(inLine, splitLetter, '\t');
_words.split(inLine, '\t');

if (_words.numWords() < 10) {
_words.erase();
Expand All @@ -66,9 +66,9 @@ public:
_formats = _words[8];
_samples = _words[9];

_arr_alts. split(_alts, splitLetter, ',');
_arr_formats.split(_formats, splitLetter, ':');
_arr_samples.split(_samples, splitLetter, ':');
_arr_alts. split(_alts, ',');
_arr_formats.split(_formats, ':');
_arr_samples.split(_samples, ':');

_isValid = true;

Expand Down Expand Up @@ -99,7 +99,7 @@ public:
return(string(line));
}

// To enfore that this is a read-only object, there are only accessors
// To enforce that this is a read-only object, there are only accessors
// that don't allow modifications.
//
// Not all data is even accessed.
Expand Down

0 comments on commit bc5fd39

Please sign in to comment.