FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
htslib/sam_internal.h at develop · SelfHacked/htslib · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Jun 3, 2021. It is now read-only.
SelfHacked
/
htslib
Public archive
forked from
samtools/htslib
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
htslib
/
sam_internal.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
101 lines (83 loc) · 3.29 KB
Breadcrumbs
htslib
/
sam_internal.h
Copy path
File metadata and controls
101 lines (83 loc) · 3.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/* sam_internal.h -- internal functions; not part of the public API.
Copyright (C) 2019-2020 Genome Research Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. */
#ifndef
HTSLIB_SAM_INTERNAL_H
#define
HTSLIB_SAM_INTERNAL_H
#include
<errno.h>
#include
<stdint.h>
#include
"htslib/sam.h"
#ifdef
__cplusplus
extern
"C"
{
#endif
// Used internally in the SAM format multi-threading.
int
sam_state_destroy
(
samFile
*
fp
);
int
sam_set_thread_pool
(
htsFile
*
fp
,
htsThreadPool
*
p
);
int
sam_set_threads
(
htsFile
*
fp
,
int
nthreads
);
// bam1_t data (re)allocation
int
sam_realloc_bam_data
(
bam1_t
*
b
,
size_t
desired
);
static
inline
int
realloc_bam_data
(
bam1_t
*
b
,
size_t
desired
)
{
if
(
desired
<=
b
->
m_data
)
return
0
;
return
sam_realloc_bam_data
(
b
,
desired
);
}
static
inline
int
possibly_expand_bam_data
(
bam1_t
*
b
,
size_t
bytes
) {
size_t
new_len
=
(
size_t
)
b
->
l_data
+
bytes
;
if
(
new_len
>
INT32_MAX
||
new_len
<
bytes
) {
// Too big or overflow
errno
=
ENOMEM
;
return
-1
;
}
if
(
new_len
<=
b
->
m_data
)
return
0
;
return
sam_realloc_bam_data
(
b
,
new_len
);
}
/*
* Convert a nibble encoded BAM sequence to a string of bases.
*
* We do this 2 bp at a time for speed. Equiv to:
*
* for (i = 0; i < len; i++)
* seq[i] = seq_nt16_str[bam_seqi(nib, i)];
*/
static
inline
void
nibble2base
(
uint8_t
*
nib
,
char
*
seq
,
int
len
) {
static
const
char
code2base
[
512
]
=
"===A=C=M=G=R=S=V=T=W=Y=H=K=D=B=N"
"A=AAACAMAGARASAVATAWAYAHAKADABAN"
"C=CACCCMCGCRCSCVCTCWCYCHCKCDCBCN"
"M=MAMCMMMGMRMSMVMTMWMYMHMKMDMBMN"
"G=GAGCGMGGGRGSGVGTGWGYGHGKGDGBGN"
"R=RARCRMRGRRRSRVRTRWRYRHRKRDRBRN"
"S=SASCSMSGSRSSSVSTSWSYSHSKSDSBSN"
"V=VAVCVMVGVRVSVVVTVWVYVHVKVDVBVN"
"T=TATCTMTGTRTSTVTTTWTYTHTKTDTBTN"
"W=WAWCWMWGWRWSWVWTWWWYWHWKWDWBWN"
"Y=YAYCYMYGYRYSYVYTYWYYYHYKYDYBYN"
"H=HAHCHMHGHRHSHVHTHWHYHHHKHDHBHN"
"K=KAKCKMKGKRKSKVKTKWKYKHKKKDKBKN"
"D=DADCDMDGDRDSDVDTDWDYDHDKDDDBDN"
"B=BABCBMBGBRBSBVBTBWBYBHBKBDBBBN"
"N=NANCNMNGNRNSNVNTNWNYNHNKNDNBNN"
;
int
i
,
len2
=
len
/
2
;
seq
[
0
]
=
0
;
for
(
i
=
0
;
i
<
len2
;
i
++
)
// Note size_t cast helps gcc optimiser.
memcpy
(
&
seq
[
i
*
2
],
&
code2base
[(
size_t
)
nib
[
i
]
*
2
],
2
);
if
((
i
*=
2
)
<
len
)
seq
[
i
]
=
seq_nt16_str
[
bam_seqi
(
nib
,
i
)];
}
#ifdef
__cplusplus
}
#endif
#endif
Back
|
FazBrowse Home
|
New Git URL