Remove ablang2.pretrained dependency - add local format_seq_input implementation
Browse files- adapter.py +28 -1
adapter.py
CHANGED
|
@@ -116,7 +116,34 @@ class AbLang2PairedHuggingFaceAdapter(AbEncoding, AbRestore, AbAlignment, AbScor
|
|
| 116 |
"""
|
| 117 |
Use different modes for different usecases, mimicking the original pretrained class.
|
| 118 |
"""
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
valid_modes = [
|
| 122 |
'rescoding', 'seqcoding', 'restore', 'likelihood', 'probability',
|
|
|
|
| 116 |
"""
|
| 117 |
Use different modes for different usecases, mimicking the original pretrained class.
|
| 118 |
"""
|
| 119 |
+
# Local implementation of format_seq_input
|
| 120 |
+
def format_seq_input(seqs, fragmented=False):
|
| 121 |
+
"""Format input sequences for processing."""
|
| 122 |
+
if fragmented:
|
| 123 |
+
# For fragmented sequences, assume they're already in the right format
|
| 124 |
+
return seqs, 'HL'
|
| 125 |
+
|
| 126 |
+
# For paired sequences, format them as VH|VL
|
| 127 |
+
formatted_seqs = []
|
| 128 |
+
for seq in seqs:
|
| 129 |
+
if isinstance(seq, (list, tuple)):
|
| 130 |
+
if len(seq) == 2:
|
| 131 |
+
# Heavy and light chain
|
| 132 |
+
heavy, light = seq[0], seq[1]
|
| 133 |
+
if heavy and light:
|
| 134 |
+
formatted_seqs.append(f"{heavy}|{light}")
|
| 135 |
+
elif heavy:
|
| 136 |
+
formatted_seqs.append(heavy)
|
| 137 |
+
elif light:
|
| 138 |
+
formatted_seqs.append(light)
|
| 139 |
+
else:
|
| 140 |
+
formatted_seqs.append("")
|
| 141 |
+
else:
|
| 142 |
+
formatted_seqs.append(seq[0] if seq else "")
|
| 143 |
+
else:
|
| 144 |
+
formatted_seqs.append(seq)
|
| 145 |
+
|
| 146 |
+
return formatted_seqs, 'HL'
|
| 147 |
|
| 148 |
valid_modes = [
|
| 149 |
'rescoding', 'seqcoding', 'restore', 'likelihood', 'probability',
|