Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BIOINF588
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Etienne MORICE
BIOINF588
Commits
a134e725
Commit
a134e725
authored
6 years ago
by
Amaury LEROY
Browse files
Options
Downloads
Patches
Plain Diff
Create tree_generator.py
parent
9fad68fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree_generator.py
+33
-0
33 additions, 0 deletions
tree_generator.py
with
33 additions
and
0 deletions
tree_generator.py
0 → 100644
+
33
−
0
View file @
a134e725
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 29 14:59:19 2019
@author: Amaury Leroy
"""
import
numpy
as
np
from
Bio.SeqRecord
import
SeqRecord
from
Bio.Cluster
import
treecluster
import
alignementseq
from
scipy.cluster.hierarchy
import
average
,
dendrogram
seqs
=
[
SeqRecord
(
'
TAACCCCAAAAGAACCAGA
'
),
SeqRecord
(
'
TTCTGTAGTAGAGATGGAATTAAGAAAAAACCATCAACTATAACCCCAAAAGAACCAGA
'
),
SeqRecord
(
'
TTCTGTAGTAGAGATGGAATTAAGAAAAAACCATCAACTATAACCCCAAAAGAACCAGA
'
),
SeqRecord
(
'
GTAGTAGAGATGGAATTAAGAAAAAACCATCAACTATAACCCCAAGAGAACCAGA
'
),
SeqRecord
(
'
GAGCCGGATGAGAAGAAACTCTCATGTCCGGTTCTGTAGTAGAGATGGAATTAAGAAAAAACCATCAACTATAACCCCAAGAGAACCAGA
'
),
SeqRecord
(
'
TTTTCATTCGCGAGGAGCCGGATGAGAAGAAACTCTCATGTCCGGTTCTGTAGTAGAGATGGAATTAAGAAAAAACCATCAACTATAACCCCAAGAGAACCAGA
'
)]
#Arguments : une liste de séquences, une fonction d'alignement
score_gap
=
-
8
def
tree_build
(
seqs
,
align
):
len_seqs
=
[
len
(
seq
)
for
seq
in
seqs
]
M
=
np
.
zeros
((
len
(
seqs
),
len
(
seqs
)))
for
i
in
range
(
len
(
seqs
)):
for
j
in
range
(
i
):
M
[
i
][
j
],
a
,
b
=
align
(
seqs
[
i
],
seqs
[
j
])
M
[
i
][
j
]
=
1
-
abs
(
M
[
i
][
j
]
/
(
max
(
len_seqs
)
*
(
11
-
score_gap
)))
print
(
type
(
M
),
M
)
# tree = treecluster(None, distancematrix=M, method = 'a', dist = 'e',)
tree
=
average
(
M
)
return
tree
tree
=
tree_build
(
seqs
,
alignementseq
.
align2steps
)
print
(
tree
)
dn
=
dendrogram
(
tree
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment