Skip to content

Commit

Permalink
Fix issue with blosum matrix file having to be located in the pwd
Browse files Browse the repository at this point in the history
  • Loading branch information
morispi committed Feb 13, 2019
1 parent 1b99156 commit ffe5ed3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
12 changes: 6 additions & 6 deletions CONSENT-correct
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ LRSCs=$(readlink -f "$0")
LRSCf=$(dirname $LRSCs)

echo "["$(date)"] Self-aligning the long reads (minimap2)"
if [[ $minimapOptions == "PB" ]] ; then
$LRSCf/minimap2/minimap2 --dual=yes -PD --no-long-join -w5 -g1000 -m30 -n1 -I100G -t"$nproc" "$reads" "$reads" > $tmpdir/"$alignments"
else
$LRSCf/minimap2/minimap2 -k15 -w5 -m100 -g10000 -r2000 --max-chain-skip 25 --dual=yes -PD --no-long-join -I100G -t"$nproc" "$reads" "$reads" > $tmpdir/"$alignments"
fi
#if [[ $minimapOptions == "PB" ]] ; then
# $LRSCf/minimap2/minimap2 --dual=yes -PD --no-long-join -w5 -g1000 -m30 -n1 -I100G -t"$nproc" "$reads" "$reads" > $tmpdir/"$alignments"
#else
# $LRSCf/minimap2/minimap2 -k15 -w5 -m100 -g10000 -r2000 --max-chain-skip 25 --dual=yes -PD --no-long-join -I100G -t"$nproc" "$reads" "$reads" > $tmpdir/"$alignments"
#fi

echo "["$(date)"] Correcting the long reads"
$LRSCf/bin/CONSENT -a $tmpdir/"$alignments" -s "$minSupport" -S "$maxSupport" -l "$windowSize" -k "$merSize" -c "$commonKMers" -A "$minAnchors" -f "$solid" -m "$windowOverlap" -j "$nproc" -r "$reads" -M "$maxMSA" >> "$out"
$LRSCf/bin/CONSENT -a Alignments_16868.paf -s "$minSupport" -S "$maxSupport" -l "$windowSize" -k "$merSize" -c "$commonKMers" -A "$minAnchors" -f "$solid" -m "$windowOverlap" -j "$nproc" -r "$reads" -M "$maxMSA" -p "$LRSCf" >> "$out"
echo "["$(date)"] Removing the temporary files"
rm $tmpdir/"$alignments"
echo "["$(date)"] Exiting"
3 changes: 2 additions & 1 deletion CONSENT-polish
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ sort -k1 -T $tmpdir --parallel"$nproc" $tmpdir/"formatted_$alignments" > $tmpdir


echo "["$(date)"] Polishing the contigs"
$LRSCf/bin/CONSENT -a $tmpdir/"$alignments" -s "$minSupport" -S "$maxSupport" -l "$windowSize" -k "$merSize" -c "$commonKMers" -A "$minAnchors" -f "$solid" -m "$windowOverlap" -j "$nproc" -r "$contigs" -R "$reads" -M "$maxMSA" >> "$out"echo "["$(date)"] Removing the temporary files"
$LRSCf/bin/CONSENT -a $tmpdir/"$alignments" -s "$minSupport" -S "$maxSupport" -l "$windowSize" -k "$merSize" -c "$commonKMers" -A "$minAnchors" -f "$solid" -m "$windowOverlap" -j "$nproc" -r "$contigs" -R "$reads" -M "$maxMSA" -p "$LRSCf" >> "$out"
echo "["$(date)"] Removing the temporary files"
rm $tmpdir/"$alignments"
echo "["$(date)"] Exiting"
14 changes: 7 additions & 7 deletions src/CONSENT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ std::string weightConsensus(std::string& consensus, std::vector<std::string>& pi
return consensus;
}

std::pair<std::string, std::unordered_map<kmer, unsigned>> computeConsensuses(std::string& readId, std::vector<std::string> & piles, std::pair<unsigned, unsigned>& pilesPos, unsigned& minSupport, unsigned& merSize, unsigned& commonKMers, unsigned& minAnchors, unsigned& solidThresh, unsigned& windowSize, unsigned maxMSA) {
std::pair<std::string, std::unordered_map<kmer, unsigned>> computeConsensuses(std::string& readId, std::vector<std::string> & piles, std::pair<unsigned, unsigned>& pilesPos, unsigned& minSupport, unsigned& merSize, unsigned& commonKMers, unsigned& minAnchors, unsigned& solidThresh, unsigned& windowSize, unsigned maxMSA, std::string path) {
int bmeanSup;
bmeanSup = std::min((int) commonKMers, (int) piles.size() / 2);
std::pair<std::vector<std::vector<std::string>>, std::unordered_map<kmer, unsigned>> rOut = MSABMAAC(piles, merSize, bmeanSup, solidThresh, minAnchors, maxMSA);
std::pair<std::vector<std::vector<std::string>>, std::unordered_map<kmer, unsigned>> rOut = MSABMAAC(piles, merSize, bmeanSup, solidThresh, minAnchors, maxMSA, path);

if (rOut.first.size() == 0) {
return std::make_pair("", rOut.second);
Expand Down Expand Up @@ -512,7 +512,7 @@ std::unordered_map<std::string, std::string> getSequencesMap(std::vector<Alignme
return sequences;
}

std::pair<std::string, std::string> processRead(int id, std::vector<Alignment>& alignments, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors,unsigned solidThresh, unsigned windowOverlap, unsigned maxMSA) {
std::pair<std::string, std::string> processRead(int id, std::vector<Alignment>& alignments, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors,unsigned solidThresh, unsigned windowOverlap, unsigned maxMSA, std::string path) {
std::string readId = alignments.begin()->qName;
std::unordered_map<std::string, std::string> sequences = getSequencesMap(alignments);
std::vector<std::pair<unsigned, unsigned>> pilesPos = getAlignmentPilesPositions(alignments.begin()->qLength, alignments, minSupport, maxSupport, windowSize, windowOverlap);
Expand All @@ -530,7 +530,7 @@ std::pair<std::string, std::string> processRead(int id, std::vector<Alignment>&
for (i = 0; i < pilesPos.size(); i++) {
curPile = getAlignmentPileSeq(alignments, minSupport, windowSize, windowOverlap, sequences, pilesPos[i].first, pilesPos[i].second, merSize, maxSupport);
templates[i] = curPile[0];
resCons = computeConsensuses(readId, curPile, pilesPos[i], minSupport, merSize, commonKMers, minAnchors, solidThresh, windowSize, maxMSA);
resCons = computeConsensuses(readId, curPile, pilesPos[i], minSupport, merSize, commonKMers, minAnchors, solidThresh, windowSize, maxMSA, path);
if (resCons.first.length() < merSize) {
consensuses[i] = resCons.first;
} else {
Expand Down Expand Up @@ -595,7 +595,7 @@ std::vector<Alignment> getNextReadPile(std::ifstream& f) {
return curReadAlignments;
}

void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned nbThreads, std::string readsFile, std::string proofFile, unsigned maxMSA) {
void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned nbThreads, std::string readsFile, std::string proofFile, unsigned maxMSA, std::string path) {
std::ifstream f(alignmentFile);
std::vector<Alignment> curReadAlignments;
std::string curRead, line;
Expand All @@ -621,7 +621,7 @@ void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxS
while (curReadAlignments.size() == 0 and !f.eof()) {
curReadAlignments = getNextReadPile(f);
}
results[i] = myPool.push(processRead, curReadAlignments, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, maxMSA);
results[i] = myPool.push(processRead, curReadAlignments, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, maxMSA, path);
jobsLoaded++;
}

Expand All @@ -641,7 +641,7 @@ void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxS
while (curReadAlignments.size() == 0 and !f.eof()) {
curReadAlignments = getNextReadPile(f);
}
results[curJob] = myPool.push(processRead, curReadAlignments, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, maxMSA);
results[curJob] = myPool.push(processRead, curReadAlignments, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, maxMSA, path);
jobsLoaded++;

// Increment the current job nb, and loop if needed
Expand Down
8 changes: 4 additions & 4 deletions src/CONSENT.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ std::string polishCorrection(std::string correctedRead, std::unordered_map<kmer,

void removeBadSequences(std::vector<std::string>& sequences, std::string tplSeq, std::unordered_map<std::string, unsigned>& merCounts, unsigned merSize, unsigned commonKMers, unsigned solidThresh, unsigned windowSize);

std::pair<std::string, std::unordered_map<kmer, unsigned>> computeConsensuses(std::string& readId, std::vector<std::string>& piles, std::pair<unsigned, unsigned>& pilesPos, unsigned& minSupport, unsigned& merSize, unsigned& commonKMers, unsigned& minAnchors, unsigned& solidThresh, unsigned& windowSize, unsigned maxMSA);
std::pair<std::string, std::unordered_map<kmer, unsigned>> computeConsensuses(std::string& readId, std::vector<std::string>& piles, std::pair<unsigned, unsigned>& pilesPos, unsigned& minSupport, unsigned& merSize, unsigned& commonKMers, unsigned& minAnchors, unsigned& solidThresh, unsigned& windowSize, unsigned maxMSA, std::string path);

std::string alignConsensuses(std::string rawRead, std::string sequence, std::vector<std::string>& consensuses, std::vector<std::unordered_map<kmer, unsigned>>& merCounts, std::vector<std::pair<unsigned, unsigned>>& pilesPos, std::vector<std::string>& templates, int startPos, unsigned windowSize, unsigned windowOverlap, unsigned solidThresh, unsigned merSize);

std::pair<std::string, std::string> processRead(int id, std::vector<Alignment>& alignments, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned maxMSA);
std::pair<std::string, std::string> processRead(int id, std::vector<Alignment>& alignments, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned maxMSA, std::string path);

void processReads(std::vector<std::vector<std::string>>& reads, unsigned minSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned solidThresh, unsigned windowOverlap);
void processReads(std::vector<std::vector<std::string>>& reads, unsigned minSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned solidThresh, unsigned windowOverlap, std::string path);

void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned nbThreads, std::string readsFile, std::string proofFile, unsigned maxMSA);
void runCorrection(std::string alignmentFile, unsigned minSupport, unsigned maxSupport, unsigned windowSize, unsigned merSize, unsigned commonKMers, unsigned minAnchors, unsigned solidThresh, unsigned windowOverlap, unsigned nbThreads, std::string readsFile, std::string proofFile, unsigned maxMSA, std::string path);

8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}

std::string alignmentFile, readsFile, proofFile;
std::string alignmentFile, readsFile, proofFile, path;
alignmentFile = "";
readsFile = "";
unsigned minSupport, maxSupport, maxMSA, windowSize, nbThreads, opt, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, nbReads;
Expand Down Expand Up @@ -62,6 +62,10 @@ int main(int argc, char* argv[]) {
case 'R':
proofFile = optarg;
break;
case 'p':
path = optarg;
path += + "/BMEAN/BOA/blosum80.mat";
break;
case 'n':
nbReads = atoi(optarg);
break;
Expand All @@ -74,7 +78,7 @@ int main(int argc, char* argv[]) {
}
}

runCorrection(alignmentFile, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, nbThreads, readsFile, proofFile, maxMSA);
runCorrection(alignmentFile, minSupport, maxSupport, windowSize, merSize, commonKMers, minAnchors, solidThresh, windowOverlap, nbThreads, readsFile, proofFile, maxMSA, path);

return EXIT_SUCCESS;
}

0 comments on commit ffe5ed3

Please sign in to comment.