-
Notifications
You must be signed in to change notification settings - Fork 67
/
AlignmentResult.cpp
107 lines (81 loc) · 2.71 KB
/
AlignmentResult.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*++
Module Name:
AlignmentResult.cpp
Abstract:
Code for SNAP genome alignment results
Authors:
Bill Bolosky, March, 2015
Environment:
Revision History:
--*/
#include "stdafx.h"
#include "AlignmentResult.h"
#include "GenomeIndex.h"
int
SingleAlignmentResult::compareByContigAndScore(const void *first_, const void *second_)
{
extern GenomeIndex *g_index; // Sorry, but no easy way to get this into here
const SingleAlignmentResult *first = (SingleAlignmentResult *)first_;
const SingleAlignmentResult *second = (SingleAlignmentResult *)second_;
int firstContig = g_index->getGenome()->getContigNumAtLocation(first->location);
int secondContig = g_index->getGenome()->getContigNumAtLocation(second->location);
if (firstContig < secondContig) {
return -1;
} else if (firstContig > secondContig) {
return 1;
} else if (first->score < second->score) {
return -1;
} else if (first->score > second->score) {
return 1;
} else {
return 0;
}
}
int
SingleAlignmentResult::compareByScore(const void *first_, const void *second_)
{
const SingleAlignmentResult *first = (SingleAlignmentResult *)first_;
const SingleAlignmentResult *second = (SingleAlignmentResult *)second_;
if (first->score < second->score) {
return -1;
} else if (first->score > second->score) {
return 1;
} else {
return 0;
}
}
int
PairedAlignmentResult::compareByContigAndScore(const void *first_, const void *second_)
{
extern GenomeIndex *g_index; // Sorry, but no easy way to get this into here
const PairedAlignmentResult *first = (PairedAlignmentResult *)first_;
const PairedAlignmentResult *second = (PairedAlignmentResult *)second_;
int firstContig = g_index->getGenome()->getContigNumAtLocation(first->location[0]);
int secondContig = g_index->getGenome()->getContigNumAtLocation(second->location[0]);
if (firstContig < secondContig) {
return -1;
} else if (firstContig > secondContig) {
return 1;
} else if (first->score < second->score) {
return -1;
} else if (first->score > second->score) {
return 1;
} else {
return 0;
}
}
int
PairedAlignmentResult::compareByScore(const void *first_, const void *second_)
{
const PairedAlignmentResult *first = (PairedAlignmentResult *)first_;
const PairedAlignmentResult *second = (PairedAlignmentResult *)second_;
int firstScore = first->score[0] + first->score[1];
int secondScore = second->score[0] + second->score[1];
if (firstScore < secondScore) {
return -1;
} else if (firstScore > secondScore) {
return 1;
} else {
return 0;
}
}