Skip to content

Commit

Permalink
Creating the provean supporting set can fail if the protein starts wi…
Browse files Browse the repository at this point in the history
…th a weird amino acid (e.g. 'X', etc.). Fixed.
  • Loading branch information
ostrokach committed Apr 16, 2015
1 parent 4235c3a commit b7f17ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions elaspic/domain_alignment.py
Expand Up @@ -160,8 +160,11 @@ def build_provean_supporting_set(
"""
"""
# Get the required parameters
first_aa = uniprot_sequence[0]
domain_mutation = '{0}1{0}'.format(first_aa)
any_position = 0
while uniprot_sequence[any_position] not in hf.canonical_amino_acids:
any_position += 1
first_aa = uniprot_sequence[any_position]
domain_mutation = '{0}{1}{0}'.format(first_aa, any_position+1)

uniprot_seqrecord = SeqRecord(
seq=Seq(uniprot_sequence), id=str(uniprot_id), description=uniprot_name)
Expand All @@ -182,10 +185,18 @@ def build_provean_supporting_set(
logger.error(error_message)
raise errors.ProveanError(error_message)

provean_supset_length = None
for line in result.split('\n'):
if 'Number of supporting sequences used:' in line:
provean_supset_length = int(line.split()[-1])

if provean_supset_length is None:
logger.error('Provean supporting set length could not be estimated. This is an error!')
logger.error('Provean result: {}'.format(result))
logger.error('Provean error_message: {}'.format(error_message))
logger.error('Provean return_code: {}'.format(return_code))
logger.error('Uniprot sequence: {}'.format(uniprot_sequence))
logger.error('First amino acid: {}'.format(first_aa))
logger.error('Domain mutation: {}'.format(domain_mutation))
return provean_supset_filename, provean_supset_length


Expand Down
1 change: 1 addition & 0 deletions elaspic/helper_functions.py
Expand Up @@ -24,6 +24,7 @@


#%%
canonical_amino_acids = 'ARNDCEQGHILKMFPSTWYV'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
logger = None

Expand Down
2 changes: 1 addition & 1 deletion tests/test_database.py
Expand Up @@ -55,7 +55,7 @@
psql_command_template = r""" \
copy {db_schema}.{table_name} \
from '{organism_folder}/{table_name}.tsv' \
with csv delimiter E'\t' null '\N' escape '\\'
with csv delimiter E'\t' null '\N' escape '\\\\'
"""

def _format_configs(configs, table_name):
Expand Down

0 comments on commit b7f17ea

Please sign in to comment.