Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing randomness for template selection #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions antibody/antibody.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from optparse import OptionParser, IndentedHelpFormatter
from time import time
import random

_script_path_ = os.path.dirname( os.path.realpath(__file__) )

Expand Down Expand Up @@ -987,13 +988,18 @@ def try_to_float(v):
else:
selected_template = table[0]['subject-id']
else: # if there is no template... table is a list, which has a blast result
pdb_entries_of_same_length=[]
for v in cdr_info.items():
check_length = '%s_length' % k
if len_cdr == int(v[1][check_length]):
pdb_random = v[0]
break
print '\nWARNING: No template avaliable for %s after filtering! Using a random template of the same length as the query\n' % k
selected_template = pdb_random
pdb_entries_of_same_length.append(v[0])
print '\n\nWARNING: No template avaliable for %s after filtering! Seeking templates of the same length %d as the query.\n' % (k,len_cdr)
if 0 == len(pdb_entries_of_same_length):
print 'ERROR: Could not find any template with that same length.\n'
sys.exit(1)
else:
print 'INFO: Making a random choice from %d entries found featuring %s with length %d.\n' % (len(pdb_entries_of_same_length),k,len_cdr)
selected_template = random.choice(pdb_entries_of_same_length)
#sys.exit(1)
print "%s template: %s" % (k, selected_template)
else:
Expand Down