-
Notifications
You must be signed in to change notification settings - Fork 6
Output formats
AlexGW edited this page Apr 16, 2025
·
17 revisions
After instantiating and running the model on some sequences, the output is a dictionary of dictionaries of the format {query_name:meta_dict}.
from anarcii import Anarcii
model = Anarcii(seq_type="antibody")
seqs = ["DVVMTQTPLSLPVSLGDQASISCRSSQSLVHSNGNTYLNWYLQKAGQSPKLLIYKVSNRFSGVPDRFSGSGSGTDFTLKISRVEAEDLGIYFCSQTTHVPPTFGGGTKLEIKR",
"LPGARCAYDMTQTPASVEVAVGGTVTIKCQASQSISTYLSWYQQKPGQRPKLLIYRASTLASGVSSRFKGSGSGTEFTLTISGVECADAATYYCQQGWSSSNVENVFGGGTEVVVKG"]
# A dict of dicts
results = model.number(seqs)print(results["Sequence 1"])
print(results["Sequence 2"]){'numbering': [((1, ' '), 'D'), ((2, ' '), 'V'), ((3, ' '), 'V'), ((4, ' '), 'M'), ((5, ' '), 'T'), ((6, ' '), 'Q'), ((7, ' '), 'T'), ((8, ' '), 'P'), ((9, ' '), 'L'), ((10, ' '), 'S'), ((11, ' '), 'L'), ((12, ' '), 'P'), ((13, ' '), 'V'), ((14, ' '), 'S'), ((15, ' '), 'L'), ((16, ' '), 'G'), ((17, ' '), 'D'), ((18, ' '), 'Q'), ((19, ' '), 'A'), ((20, ' '), 'S'), ((21, ' '), 'I'), ((22, ' '), 'S'), ((23, ' '), 'C'), ((24, ' '), 'R'), ((25, ' '), 'S'), ((26, ' '), 'S'), ((27, ' '), 'Q'), ((28, ' '), 'S'), ((29, ' '), 'L'), ((30, ' '), 'V'), ((31, ' '), 'H'), ((32, ' '), 'S'), ((33, ' '), '-'), ((34, ' '), 'N'), ((35, ' '), 'G'), ((36, ' '), 'N'), ((37, ' '), 'T'), ((38, ' '), 'Y'), ((39, ' '), 'L'), ((40, ' '), 'N'), ((41, ' '), 'W'), ((42, ' '), 'Y'), ((43, ' '), 'L'), ((44, ' '), 'Q'), ((45, ' '), 'K'), ((46, ' '), 'A'), ((47, ' '), 'G'), ((48, ' '), 'Q'), ((49, ' '), 'S'), ((50, ' '), 'P'), ((51, ' '), 'K'), ((52, ' '), 'L'), ((53, ' '), 'L'), ((54, ' '), 'I'), ((55, ' '), 'Y'), ((56, ' '), 'K'), ((57, ' '), 'V'), ((58, ' '), '-'), ((59, ' '), '-'), ((60, ' '), '-'), ((61, ' '), '-'), ((62, ' '), '-'), ((63, ' '), '-'), ((64, ' '), '-'), ((65, ' '), 'S'), ((66, ' '), 'N'), ((67, ' '), 'R'), ((68, ' '), 'F'), ((69, ' '), 'S'), ((70, ' '), 'G'), ((71, ' '), 'V'), ((72, ' '), 'P'), ((73, ' '), '-'), ((74, ' '), 'D'), ((75, ' '), 'R'), ((76, ' '), 'F'), ((77, ' '), 'S'), ((78, ' '), 'G'), ((79, ' '), 'S'), ((80, ' '), 'G'), ((81, ' '), '-'), ((82, ' '), '-'), ((83, ' '), 'S'), ((84, ' '), 'G'), ((85, ' '), 'T'), ((86, ' '), 'D'), ((87, ' '), 'F'), ((88, ' '), 'T'), ((89, ' '), 'L'), ((90, ' '), 'K'), ((91, ' '), 'I'), ((92, ' '), 'S'), ((93, ' '), 'R'), ((94, ' '), 'V'), ((95, ' '), 'E'), ((96, ' '), 'A'), ((97, ' '), 'E'), ((98, ' '), 'D'), ((99, ' '), 'L'), ((100, ' '), 'G'), ((101, ' '), 'I'), ((102, ' '), 'Y'), ((103, ' '), 'F'), ((104, ' '), 'C'), ((105, ' '), 'S'), ((106, ' '), 'Q'), ((107, ' '), 'T'), ((108, ' '), 'T'), ((109, ' '), 'H'), ((110, ' '), '-'), ((111, ' '), '-'), ((112, ' '), '-'), ((113, ' '), '-'), ((114, ' '), 'V'), ((115, ' '), 'P'), ((116, ' '), 'P'), ((117, ' '), 'T'), ((118, ' '), 'F'), ((119, ' '), 'G'), ((120, ' '), 'G'), ((121, ' '), 'G'), ((122, ' '), 'T'), ((123, ' '), 'K'), ((124, ' '), 'L'), ((125, ' '), 'E'), ((126, ' '), 'I'), ((127, ' '), 'K'), ((128, ' '), '-')], 'chain_type': 'K', 'score': 30.66534996032715, 'query_start': 0, 'query_end': 111, 'error': None, 'scheme': 'imgt'}
{'numbering': [((1, ' '), 'A'), ((2, ' '), 'Y'), ((3, ' '), 'D'), ((4, ' '), 'M'), ((5, ' '), 'T'), ((6, ' '), 'Q'), ((7, ' '), 'T'), ((8, ' '), 'P'), ((9, ' '), 'A'), ((10, ' '), 'S'), ((11, ' '), 'V'), ((12, ' '), 'E'), ((13, ' '), 'V'), ((14, ' '), 'A'), ((15, ' '), 'V'), ((16, ' '), 'G'), ((17, ' '), 'G'), ((18, ' '), 'T'), ((19, ' '), 'V'), ((20, ' '), 'T'), ((21, ' '), 'I'), ((22, ' '), 'K'), ((23, ' '), 'C'), ((24, ' '), 'Q'), ((25, ' '), 'A'), ((26, ' '), 'S'), ((27, ' '), 'Q'), ((28, ' '), 'S'), ((29, ' '), 'I'), ((30, ' '), '-'), ((31, ' '), '-'), ((32, ' '), '-'), ((33, ' '), '-'), ((34, ' '), '-'), ((35, ' '), '-'), ((36, ' '), 'S'), ((37, ' '), 'T'), ((38, ' '), 'Y'), ((39, ' '), 'L'), ((40, ' '), 'S'), ((41, ' '), 'W'), ((42, ' '), 'Y'), ((43, ' '), 'Q'), ((44, ' '), 'Q'), ((45, ' '), 'K'), ((46, ' '), 'P'), ((47, ' '), 'G'), ((48, ' '), 'Q'), ((49, ' '), 'R'), ((50, ' '), 'P'), ((51, ' '), 'K'), ((52, ' '), 'L'), ((53, ' '), 'L'), ((54, ' '), 'I'), ((55, ' '), 'Y'), ((56, ' '), 'R'), ((57, ' '), 'A'), ((58, ' '), '-'), ((59, ' '), '-'), ((60, ' '), '-'), ((61, ' '), '-'), ((62, ' '), '-'), ((63, ' '), '-'), ((64, ' '), '-'), ((65, ' '), 'S'), ((66, ' '), 'T'), ((67, ' '), 'L'), ((68, ' '), 'A'), ((69, ' '), 'S'), ((70, ' '), 'G'), ((71, ' '), 'V'), ((72, ' '), 'S'), ((73, ' '), '-'), ((74, ' '), 'S'), ((75, ' '), 'R'), ((76, ' '), 'F'), ((77, ' '), 'K'), ((78, ' '), 'G'), ((79, ' '), 'S'), ((80, ' '), 'G'), ((81, ' '), '-'), ((82, ' '), '-'), ((83, ' '), 'S'), ((84, ' '), 'G'), ((85, ' '), 'T'), ((86, ' '), 'E'), ((87, ' '), 'F'), ((88, ' '), 'T'), ((89, ' '), 'L'), ((90, ' '), 'T'), ((91, ' '), 'I'), ((92, ' '), 'S'), ((93, ' '), 'G'), ((94, ' '), 'V'), ((95, ' '), 'E'), ((96, ' '), 'C'), ((97, ' '), 'A'), ((98, ' '), 'D'), ((99, ' '), 'A'), ((100, ' '), 'A'), ((101, ' '), 'T'), ((102, ' '), 'Y'), ((103, ' '), 'Y'), ((104, ' '), 'C'), ((105, ' '), 'Q'), ((106, ' '), 'Q'), ((107, ' '), 'G'), ((108, ' '), 'W'), ((109, ' '), 'S'), ((110, ' '), 'S'), ((111, ' '), '-'), ((112, ' '), 'S'), ((113, ' '), 'N'), ((114, ' '), 'V'), ((115, ' '), 'E'), ((116, ' '), 'N'), ((117, ' '), 'V'), ((118, ' '), 'F'), ((119, ' '), 'G'), ((120, ' '), 'G'), ((121, ' '), 'G'), ((122, ' '), 'T'), ((123, ' '), 'E'), ((124, ' '), 'V'), ((125, ' '), 'V'), ((126, ' '), 'V'), ((127, ' '), 'K'), ((128, ' '), '-')], 'chain_type': 'K', 'score': 29.50858497619629, 'query_start': 6, 'query_end': 115, 'error': None, 'scheme': 'imgt'}If you want the format to match how ANARCI usually outputs results, simple run the to_legacy method after numbering.
from anarcii import Anarcii
model = Anarcii(seq_type="antibody")
seq = [
"SVKVSCTSSEVTFSSFAISWVRQAPGQGLEWLGGISPMFGTPNYAQKFQGRVTITADQSTRTAYMDLRSLRSEDTAVYYCARSPSYICSGGTCVFDHWGQGTLVTVSSGGGGSG",
"LSRFTHKDVPHQGPQFIIQGYKDYVVNEVFISADRKLSTLSLPWVSLRDAAVYYCIVTDGYKDYVVNEVASLFISADRKLSTLSLPWVSLRDAAVYYCIVTD"]
results = model.number(seq)
legacy_results = model.to_legacy()
numbering, alignment_details, hit_tables = legacy_results
print(numbering[0])
print(alignment_details[0])
print(hit_tables[0])
print("\n### A failed sequence should return None. ###")
print(numbering[1])
print(alignment_details[1])
print(hit_tables[1])[([((1, ' '), '-'), ((2, ' '), '-'), ((3, ' '), '-'), ((4, ' '), '-'), ((5, ' '), '-'), ((6, ' '), '-'), ((7, ' '), '-'), ((8, ' '), '-'), ((9, ' '), '-'), ((10, ' '), '-'), ((11, ' '), '-'), ((12, ' '), '-'), ((13, ' '), '-'), ((14, ' '), '-'), ((15, ' '), '-'), ((16, ' '), '-'), ((17, ' '), '-'), ((18, ' '), 'S'), ((19, ' '), 'V'), ((20, ' '), 'K'), ((21, ' '), 'V'), ((22, ' '), 'S'), ((23, ' '), 'C'), ((24, ' '), 'T'), ((25, ' '), 'S'), ((26, ' '), 'S'), ((27, ' '), 'E'), ((28, ' '), 'V'), ((29, ' '), 'T'), ((30, ' '), 'F'), ((31, ' '), '-'), ((32, ' '), '-'), ((33, ' '), '-'), ((34, ' '), '-'), ((35, ' '), 'S'), ((36, ' '), 'S'), ((37, ' '), 'F'), ((38, ' '), 'A'), ((39, ' '), 'I'), ((40, ' '), 'S'), ((41, ' '), 'W'), ((42, ' '), 'V'), ((43, ' '), 'R'), ((44, ' '), 'Q'), ((45, ' '), 'A'), ((46, ' '), 'P'), ((47, ' '), 'G'), ((48, ' '), 'Q'), ((49, ' '), 'G'), ((50, ' '), 'L'), ((51, ' '), 'E'), ((52, ' '), 'W'), ((53, ' '), 'L'), ((54, ' '), 'G'), ((55, ' '), 'G'), ((56, ' '), 'I'), ((57, ' '), 'S'), ((58, ' '), 'P'), ((59, ' '), 'M'), ((60, ' '), '-'), ((61, ' '), '-'), ((62, ' '), 'F'), ((63, ' '), 'G'), ((64, ' '), 'T'), ((65, ' '), 'P'), ((66, ' '), 'N'), ((67, ' '), 'Y'), ((68, ' '), 'A'), ((69, ' '), 'Q'), ((70, ' '), 'K'), ((71, ' '), 'F'), ((72, ' '), 'Q'), ((73, ' '), '-'), ((74, ' '), 'G'), ((75, ' '), 'R'), ((76, ' '), 'V'), ((77, ' '), 'T'), ((78, ' '), 'I'), ((79, ' '), 'T'), ((80, ' '), 'A'), ((81, ' '), 'D'), ((82, ' '), 'Q'), ((83, ' '), 'S'), ((84, ' '), 'T'), ((85, ' '), 'R'), ((86, ' '), 'T'), ((87, ' '), 'A'), ((88, ' '), 'Y'), ((89, ' '), 'M'), ((90, ' '), 'D'), ((91, ' '), 'L'), ((92, ' '), 'R'), ((93, ' '), 'S'), ((94, ' '), 'L'), ((95, ' '), 'R'), ((96, ' '), 'S'), ((97, ' '), 'E'), ((98, ' '), 'D'), ((99, ' '), 'T'), ((100, ' '), 'A'), ((101, ' '), 'V'), ((102, ' '), 'Y'), ((103, ' '), 'Y'), ((104, ' '), 'C'), ((105, ' '), 'A'), ((106, ' '), 'R'), ((107, ' '), 'S'), ((108, ' '), 'P'), ((109, ' '), 'S'), ((110, ' '), 'Y'), ((111, ' '), 'I'), ((111, 'A'), 'C'), ((111, 'B'), 'S'), ((112, 'B'), 'G'), ((112, 'A'), 'G'), ((112, ' '), 'T'), ((113, ' '), 'C'), ((114, ' '), 'V'), ((115, ' '), 'F'), ((116, ' '), 'D'), ((117, ' '), 'H'), ((118, ' '), 'W'), ((119, ' '), 'G'), ((120, ' '), 'Q'), ((121, ' '), 'G'), ((122, ' '), 'T'), ((123, ' '), 'L'), ((124, ' '), 'V'), ((125, ' '), 'T'), ((126, ' '), 'V'), ((127, ' '), 'S'), ((128, ' '), 'S')], 0, 107)]
[{'chain_type': 'H', 'score': 30.487, 'query_start': 0, 'query_end': 107, 'error': None, 'scheme': 'imgt', 'query_name': 'seq0', 'species': None}]
None
### A failed sequence should return None. ###
None
[{'chain_type': 'F', 'score': 0.0, 'query_start': None, 'query_end': None, 'error': 'Less than 50 non insertion residues numbered.', 'query_name': 'seq1', 'species': None, 'scheme': 'imgt'}]
None
Available schemes are kabat, martin, chothia and Aho.
from anarcii import Anarcii
model = Anarcii(seq_type="antibody")
seq = ["QVQLVQSGAEVKKPGSSVKVSCTSSEVTFSSFAISWVRQAPGQGLEWLGGISPMFGTPNYAQKFQGRVTITADQSTRTAYMDLRSLRSEDTAVYYCARSPSYICSGGTCVFDHWGQGTLVTVSSGGGGSG"]
results = model.number(seq)
model.to_scheme("martin")After running the model outputs can be written to the file type of choice using the model.to_...(file_path) methods
# Save the last seqs to a csv, or msgpack file
filename = "./example_outputs/tmp"
model.to_csv(filename + ".csv")
model.to_msgpack(filename + ".msgpack")