Skip to content

Commit 5baba58

Browse files
committed
ubuntu; v 1.1.4
1 parent 3d76deb commit 5baba58

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ pannelli
1818
paper/paper.md~
1919
TE
2020
split_sam_by_flag.pl
21+
mini_tests
22+
.vscode
23+
prova.sh

base.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <queue>
1+
#include <queue>
22
#include <vector>
33
#include <iostream>
44
#include <map>
@@ -16,7 +16,7 @@ using namespace std;
1616
typedef uint32_t DepthType; // type for depth of coverage, kept it small
1717
const char ref_char = '>'; // reference prefix for "counts" output
1818

19-
const string VERSION = "%prog 1.1.3"
19+
const string VERSION = "%prog 1.1.4"
2020
"\nCopyright (C) 2014-2019 Giovanni Birolo and Andrea Telatin\n"
2121
"https://github.com/telatin/covtobed - License MIT"
2222
".\n"
@@ -61,11 +61,17 @@ class Input {
6161
bool get_next_alignment(BamAlignment & alignment) {
6262
bool more_alignments, good_alignment;
6363
do {
64-
debug cerr << "[M] " << alignment.Name << ":" << alignment.Position << " | Is mapped? " << alignment.IsMapped() << endl;
64+
debug cerr << "[M] Read on ref#" << alignment.RefID << " pos:" << alignment.Position <<
65+
"\n\t| Is mapped? " << alignment.IsMapped() << " | AlignmentFlag:" << alignment.AlignmentFlag << endl;
6566
more_alignments = input_bams.GetNextAlignmentCore(alignment);
6667
if (discard_invalid_alignments) {
6768
good_alignment = alignment.IsMapped() && alignment.MapQuality >= min_mapq
68-
&& !alignment.IsDuplicate() && !alignment.IsFailedQC() && alignment.IsPrimaryAlignment() ;
69+
&& !alignment.IsDuplicate() && !alignment.IsFailedQC() && alignment.IsPrimaryAlignment();
70+
71+
// 1.2.0 ProperPair
72+
if (alignment.IsPaired() && ! alignment.IsProperPair() ) {
73+
good_alignment = false;
74+
}
6975
} else {
7076
good_alignment = alignment.IsMapped() && alignment.MapQuality >= min_mapq;
7177
}
@@ -210,11 +216,6 @@ int main(int argc, char *argv[]) {
210216
min_mapq = options.get("min_mapq");
211217
}
212218

213-
if (physical_coverage and only_valid) {
214-
// https://github.com/telatin/covtobed/issues/11
215-
cerr << "Parameters --physical-coverage and --discard-invalid-alignments are currently mutually exclusive." << endl;
216-
exit(0);
217-
}
218219

219220
try {
220221
// open input and output
@@ -253,6 +254,7 @@ int main(int argc, char *argv[]) {
253254
while (more_alignments_for_ref && next_change == alignment.Position) {
254255
if (physical_coverage) {
255256
if (alignment.InsertSize > 0) {
257+
debug cerr << " [phy] pos:" << alignment.Position << " size:" << alignment.InsertSize << endl;
256258
coverage_ends.push({alignment.Position + alignment.InsertSize, alignment.IsReverseStrand()});
257259
coverage.inc(alignment.IsReverseStrand());
258260
}
@@ -272,9 +274,13 @@ int main(int argc, char *argv[]) {
272274
debug cerr << "[<] Coverage is " << coverage << " from " << next_change << endl;
273275
last_pos = next_change;
274276
} while (last_pos != ref.RefLength);
275-
debug cerr << "[_] Completed at " << ref.RefName << ":" << last_pos << endl;
277+
debug cerr << "[_] Completed at " << ref.RefName << ":" << last_pos << " [coverage:" << coverage_ends.size() << "]" << endl;
276278
// reference ended
277-
assert(coverage_ends.empty());
279+
if (!coverage_ends.empty()) {
280+
cerr << "Coverage is not zero at the end of " << ref.RefName << endl;
281+
cerr << "Try samtools fixmate on the input file" << endl;
282+
}
283+
// 1.2.0 -- removed: assert(coverage_ends.empty());
278284
}
279285
//assert(!more_alignments);
280286
if (more_alignments) {

binaries/covtobed

0 Bytes
Binary file not shown.

binaries/covtobed_debug

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)