Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
87044b41
Commit
87044b41
authored
Nov 20, 2015
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified the encoding function on 2 bits a little
parent
6ab1c833
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
src/encode.c
src/encode.c
+15
-9
No files found.
src/encode.c
View file @
87044b41
...
...
@@ -53,51 +53,52 @@ bool only_ATGC(char* seq)
}
byte_t
*
encode_seq_on_2_bits
(
char
*
seq
,
int32_t
length
)
// TODO shift = 2
byte_t
*
encode_seq_on_2_bits
(
char
*
seq
,
int32_t
length
)
{
byte_t
*
seq_b
;
uint8_t
shift
;
uint8_t
modulo
;
int32_t
length_b
;
int32_t
i
;
// fprintf(stderr, "\n>>>>>>>>>>>>>>>>>>Encoding sequence %s", seq);
length_b
=
ceil
((
double
)
length
/
(
double
)
4
.
0
);
// fprintf(stderr, "\nLength: %d", length_b);
seq_b
=
(
byte_t
*
)
malloc
(
length_b
*
sizeof
(
byte_t
));
// Initialize all the bits to 0
memset
(
seq_b
,
0
,
length_b
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
shift
=
6
-
2
*
(
i
%
4
);
// fprintf(stderr, "\nshift: %u", shift)
;
// Shift of 2 to make place for new nucleotide
seq_b
[
i
/
4
]
<<=
2
;
// Add new nucleotide
switch
(
seq
[
i
])
{
case
'a'
:
case
'A'
:
seq_b
[
i
/
4
]
|=
NUC_A
<<
shift
;
seq_b
[
i
/
4
]
|=
NUC_A
;
// fprintf(stderr, "\nIn byte %d, writing A:", i/4);
// print_bits(seq_b, length_b);
break
;
case
'c'
:
case
'C'
:
seq_b
[
i
/
4
]
|=
NUC_C
<<
shift
;
seq_b
[
i
/
4
]
|=
NUC_C
;
// fprintf(stderr, "\nIn byte %d, writing C:", i/4);
// print_bits(seq_b, length_b);
break
;
case
'g'
:
case
'G'
:
seq_b
[
i
/
4
]
|=
NUC_G
<<
shift
;
seq_b
[
i
/
4
]
|=
NUC_G
;
// fprintf(stderr, "\nIn byte %d, writing G:", i/4);
// print_bits(seq_b, length_b);
break
;
case
't'
:
case
'T'
:
seq_b
[
i
/
4
]
|=
NUC_T
<<
shift
;
seq_b
[
i
/
4
]
|=
NUC_T
;
// fprintf(stderr, "\nIn byte %d, writing T:", i/4);
// print_bits(seq_b, length_b);
break
;
...
...
@@ -107,6 +108,11 @@ byte_t* encode_seq_on_2_bits(char* seq, int32_t length) // TODO shift = 2
}
}
// Final shift for the last byte if needed
modulo
=
(
length
%
4
);
if
(
modulo
)
seq_b
[(
i
-
1
)
/
4
]
<<=
(
2
*
(
4
-
modulo
));
// fprintf(stderr, "\n>>>>>>>>>Encoded:");
// print_bits(seq_b, length_b);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment