Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SENSE-PPI
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Konstantin Volzhenin
SENSE-PPI
Commits
060842aa
Commit
060842aa
authored
Dec 19, 2023
by
Konstantin Volzhenin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.6.5 updated names for tmp files for esm2 and fasta utils
parent
f5945547
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
esm2_model.py
senseppi/esm2_model.py
+14
-7
utils.py
senseppi/utils.py
+4
-2
No files found.
senseppi/esm2_model.py
View file @
060842aa
...
...
@@ -10,6 +10,7 @@ import logging
from
esm
import
FastaBatchedDataset
,
pretrained
from
copy
import
copy
from
Bio
import
SeqIO
from
datetime
import
datetime
def
add_esm_args
(
parent_parser
):
...
...
@@ -119,13 +120,19 @@ def compute_embeddings(params):
seq_dict
.
pop
(
seq_id
)
if
len
(
seq_dict
)
>
0
:
params_esm
=
copy
(
params
)
params_esm
.
fasta_file
=
Path
(
str
(
params
.
fasta_file
)
.
replace
(
'fasta'
,
'tmp.fasta'
))
with
open
(
params_esm
.
fasta_file
,
'w'
)
as
f
:
for
seq_id
in
seq_dict
.
keys
():
f
.
write
(
'>'
+
seq_id
+
'
\n
'
)
f
.
write
(
str
(
seq_dict
[
seq_id
]
.
seq
)
+
'
\n
'
)
run
(
params_esm
)
os
.
remove
(
params_esm
.
fasta_file
)
try
:
current_time
=
str
(
datetime
.
now
())
.
replace
(
' '
,
'_'
)
params_esm
.
fasta_file
=
Path
(
current_time
+
'_'
+
str
(
params
.
fasta_file
)
.
replace
(
'fasta'
,
'tmp.fasta'
))
with
open
(
params_esm
.
fasta_file
,
'w'
)
as
f
:
for
seq_id
in
seq_dict
.
keys
():
f
.
write
(
'>'
+
seq_id
+
'
\n
'
)
f
.
write
(
str
(
seq_dict
[
seq_id
]
.
seq
)
+
'
\n
'
)
run
(
params_esm
)
except
Exception
as
e
:
raise
e
finally
:
if
os
.
path
.
exists
(
params_esm
.
fasta_file
):
os
.
remove
(
params_esm
.
fasta_file
)
else
:
logging
.
info
(
'All ESM embeddings already computed'
)
...
...
senseppi/utils.py
View file @
060842aa
...
...
@@ -4,6 +4,7 @@ from senseppi import __version__
import
torch
import
logging
import
argparse
from
datetime
import
datetime
class
ArgumentParserWithDefaults
(
argparse
.
ArgumentParser
):
...
...
@@ -68,7 +69,8 @@ def block_mps(params):
def
process_string_fasta
(
fasta_file
,
min_len
,
max_len
):
with
open
(
'file.tmp'
,
'w'
)
as
f
:
tmp_name
=
str
(
datetime
.
now
())
.
replace
(
' '
,
'_'
)
+
'_fasta_processed.tmp'
with
open
(
tmp_name
,
'w'
)
as
f
:
for
record
in
SeqIO
.
parse
(
fasta_file
,
"fasta"
):
if
len
(
record
.
seq
)
<
min_len
or
len
(
record
.
seq
)
>
max_len
:
continue
...
...
@@ -78,7 +80,7 @@ def process_string_fasta(fasta_file, min_len, max_len):
SeqIO
.
write
(
record
,
f
,
"fasta"
)
# Rename the temporary file to the original file
os
.
remove
(
fasta_file
)
os
.
rename
(
'file.tmp'
,
fasta_file
)
os
.
rename
(
tmp_name
,
fasta_file
)
def
get_fasta_ids
(
fasta_file
):
...
...
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