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
0b72a7a9
Commit
0b72a7a9
authored
6 years ago
by
Ariane Delrocq
Browse files
Options
Downloads
Patches
Plain Diff
create python function for clustalo
parent
b709672e
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
alignementseq_tests.py
+52
-24
52 additions, 24 deletions
alignementseq_tests.py
with
52 additions
and
24 deletions
alignementseq_tests.py
+
52
−
24
View file @
0b72a7a9
...
...
@@ -19,6 +19,42 @@ import Bio.Entrez
from
Bio.SeqRecord
import
SeqRecord
from
Bio.SubsMat.MatrixInfo
import
blosum62
#==============================================================================
import
importlib
import
os
import
sys
import
io
spec
,
m
=
None
,
None
def
bali_score
(
ref_fasta_path
,
test_fasta_path
):
"""
Portable wrapper for the bali_score.py script.
Calculate BALI scores from a test and a reference multiple sequence alignment in FASTA format.
Reproduces the results of the bali_score C program.
"""
path
=
os
.
path
.
join
(
"
balibase
"
,
"
bali_score.py
"
)
global
spec
,
m
if
spec
is
None
:
spec
=
importlib
.
util
.
spec_from_file_location
(
"
baliscore
"
,
path
)
m
=
importlib
.
util
.
module_from_spec
(
spec
)
tmp_argv
=
sys
.
argv
tmp_stdout
=
sys
.
stdout
buf
=
sys
.
stdout
=
io
.
StringIO
()
sys
.
argv
=
[
path
,
ref_fasta_path
,
test_fasta_path
]
try
:
spec
.
loader
.
exec_module
(
m
)
finally
:
sys
.
argv
=
tmp_argv
sys
.
stdout
=
tmp_stdout
buf
.
seek
(
0
)
score
=
{}
for
line
in
buf
:
name
,
var
=
line
.
partition
(
"
=
"
)[::
2
]
score
[
name
.
strip
()]
=
float
(
var
)
return
score
#==============================================================================
class
BalibaseTestCase
(
unittest
.
TestCase
):
"""
Base class to inherit by all test cases that need access to the balibase.
"""
...
...
@@ -179,30 +215,22 @@ class AlignmentSeqTestCase(BalibaseTestCase):
print
(
ex_r2
)
raise
# =============================================================================
# def test_multiple_align(self):
# """Tests the multiple_align function (using blosum and gap extension)."""
# #from alignementseq import multiple_align
# from Bio.Align.Applications import ClustalwCommandline
# from Bio import AlignIO
# import pip
#
# if not os.path.isfile("clustalo.py"):
# print("Fetching clustalo.py from Github...")
# urllib.request.urlretrieve(
# "https://raw.githubusercontent.com/ebi-wp/webservice-clients/master/python/clustalo.py",
# "clustalo.py")
# pip.main(["install --upgrade", "xmltramp2"])
# #pip("install --upgrade xmltramp2")
# print("Done")
# import clustalo
# # How to use: python clustalo.py --email <your@email.com> --sequence sp:wap_rat,sp:wap_mouse,sp:wap_pig
#
# for records, filename in self.get_dataset_records():
# clustalo("ariane.delrocq@polytechnique.edu", *list(records))
#
# print("Fine", filename)
# =============================================================================
def
test_benchmark_multiple_align
(
self
):
"""
Tests the multiple_align function (using blosum and gap extension).
"""
#from alignementseq import multiple_align
from
Bio.Align.Applications
import
ClustalwCommandline
from
Bio
import
AlignIO
import
pip
print
(
"
Test-benchmark multiple_align
"
)
import
clustalo
as
cl
for
records
,
filename
in
list
(
self
.
get_dataset_records
())[:
3
]:
cl
.
runClustalO
(
"
ariane-la-fusee@laposte.net
"
,
"
sp:wap_rat,sp:wap_mouse,sp:wap_pig
"
,
fmt
=
'
fasta
'
)
# TODO: use real seq instead of rat, pig...
print
(
"
Fine
"
,
filename
)
def
save_alignments
(
self
,
NameFile
):
...
...
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