Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
7df238ca
Commit
7df238ca
authored
Jul 16, 2019
by
Philippe Veber
Browse files
Alistat.nucleotide_fasta_gc: compute GC stats at any pos in codon
parent
bb8a7d46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
lib/alistats.ml
lib/alistats.ml
+12
-6
No files found.
lib/alistats.ml
View file @
7df238ca
...
...
@@ -5,9 +5,9 @@ let ok_exn err = function
|
Ok
x
->
x
|
Error
e
->
failwith
(
err
e
)
let
is_gc
?
thirdpos
:
(
tp
=
false
)
i
c
=
match
t
p
with
|
true
when
not
((
i
mod
3
)
=
2
)
->
false
let
is_gc
?
pos
i
c
=
match
p
os
with
|
Some
p
when
not
((
i
mod
3
)
=
p
)
->
false
|
_
->
c
=
'
g'
||
c
=
'
G'
||
c
=
'
c'
||
c
=
'
C'
let
strings_from_fasta
fa
=
...
...
@@ -21,11 +21,17 @@ type gc_stat = {
gc_variance_among_sequences
:
float
;
}
let
nucleotide_fasta_gc
?
thirdpos
:
(
tp
=
false
)
fa
=
let
nucleotide_fasta_gc
?
pos
fa
=
let
pos
=
Option
.
map
pos
~
f
:
(
function
|
`first
->
0
|
`second
->
1
|
`third
->
2
)
in
let
seqs
=
strings_from_fasta
fa
in
let
gc_counts
=
Array
.
map
seqs
~
f
:
(
fun
seq
->
let
len
=
if
t
p
then
String
.
length
seq
/
3
else
String
.
length
seq
in
let
sum
=
String
.
foldi
~
init
:
0
~
f
:
(
fun
i
a
c
->
a
+
if
is_gc
~
thirdpos
:
tp
i
c
then
1
else
0
)
seq
in
let
len
=
if
p
os
<>
None
then
String
.
length
seq
/
3
else
String
.
length
seq
in
let
sum
=
String
.
foldi
~
init
:
0
~
f
:
(
fun
i
a
c
->
a
+
if
is_gc
?
pos
i
c
then
1
else
0
)
seq
in
float
len
,
float
sum
)
in
...
...
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