Package: iglm
IgLMOfficial repository for IgLM:Generative Language Modeling for Antibody DesignThe code and pre-trained models from this work are made available for non-commercial use under the terms of theJHU Academic Software License Agreement.SetupTo use IgLM, install via pip:pipinstalliglmAlternatively, you can clone this repository and install the package locally:$gitclonegit@github.com:Graylab/IgLM.git$pipinstallIgFoldCommand line usageIgLM supports sequence infilling, sequence generation (with prompting), and sequence evaluation from the command line.Re-design spans of an antibody sequenceTo use IgLM to re-design spans of an antibody sequence, supply the fasta file, the fasta record ID corresponding to the sequence to design, the start index of the span (0-indexed), and the end index of the span (0-indexed, exclusive).To generate 100 unique sequences of the anti-tissue factor antibody (1JPT) heavy chain with an IgLM-designed CDR3:iglm_infilldata/antibodies/1jpt/1jpt.fasta:H98106--chain_token[HEAVY]--species_token[HUMAN]--num_seqs100Full antibody sequence generationIgLM can be used to generate full antibody sequences while conditioning on the chain type and species-of-origin. See Appendix A.5 for starting tokens and sampling temperatures used for the results in the paper.To generate 100 unique human heavy chain sequences starting with EVQ:iglm_generate--prompt_sequenceEVQ--chain_token[HEAVY]--species_token[HUMAN]--num_seqs100To generate 100 unique nanobody sequences starting with QVQ:iglm_generate--prompt_sequenceQVQ--chain_token[HEAVY]--species_token[CAMEL]--num_seqs100Sequence evaluationIgLM can be used to calculate the log likelihood of a sequence given a chain type and species-of-origin.Full sequence log likelihood calculation:iglm_evaluatedata/antibodies/1jpt/1jpt.fasta:H--chain_token[HEAVY]--species_token[HUMAN]Infilled sequence log likelihood calculation:iglm_evaluatedata/antibodies/1jpt/1jpt.fasta:H--start98--end106--chain_token[HEAVY]--species_token[HUMAN]Package usageIgLM may also be used as a Python package, enabling the above use cases and more flexible usage.Re-design spans of an antibody sequenceTo use IgLM to re-design spans of an antibody sequence, supply the fasta file, the fasta record ID corresponding to the sequence to design, the start index of the span (0-indexed), and the end index of the span (0-indexed, exclusive).To generate 100 unique sequences of the anti-tissue factor antibody (1JPT) heavy chain with an IgLM-designed CDR3:fromiglmimportIgLMiglm=IgLM()parent_sequence="EVQLVESGGGLVQPGGSLRLSCAASGFNIKEYYMHWVRQAPGKGLEWVGLIDPEQGNTIYDPKFQDRATISADNSKNTAYLQMNSLRAEDTAVYYCARDTAAYFDYWGQGTLVTVS"chain_token="[HEAVY]"species_token="[HUMAN]"infill_range=(98,106)num_seqs=100generated_seqs=iglm.infill(parent_sequence,chain_token,species_token,infill_range=infill_range,num_to_generate=num_seqs,)Full antibody sequence generationIgLM can be used to generate full antibody sequences while conditioning on the chain type and species-of-origin. See Appendix A.5 for starting tokens and sampling temperatures used for the results in the paper.To generate 100 unique human heavy chain sequences starting with EVQ:fromiglmimportIgLMiglm=IgLM()prompt_sequence="EVQ"chain_token="[HEAVY]"species_token="[HUMAN]"num_seqs=100generated_seqs=iglm.generate(chain_token,species_token,prompt_sequence=prompt_sequence,num_to_generate=num_seqs,)To generate 100 unique nanobody sequences starting with QVQ:fromiglmimportIgLMiglm=IgLM()prompt_sequence="QVQ"chain_token="[HEAVY]"species_token="[CAMEL]"num_seqs=100generated_seqs=iglm.generate(chain_token,species_token,prompt_sequence=prompt_sequence,num_to_generate=num_seqs,)Sequence evaluationIgLM can be used to calculate the log likelihood of a sequence given a chain type and species-of-origin.Full sequence log likelihood calculation:importmathfromiglmimportIgLMiglm=IgLM()sequence="EVQLVESGGGLVQPGGSLRLSCAASGFNIKEYYMHWVRQAPGKGLEWVGLIDPEQGNTIYDPKFQDRATISADNSKNTAYLQMNSLRAEDTAVYYCARDTAAYFDYWGQGTLVTVS"chain_token="[HEAVY]"species_token="[HUMAN]"log_likelihood=iglm.log_likelihood(sequence,chain_token,species_token,infill_range=infill_range,)perplexity=math.exp(-log_likelihood)Infilled sequence log likelihood calculation:importmathfromiglmimportIgLMiglm=IgLM()sequence="EVQLVESGGGLVQPGGSLRLSCAASGFNIKEYYMHWVRQAPGKGLEWVGLIDPEQGNTIYDPKFQDRATISADNSKNTAYLQMNSLRAEDTAVYYCARDTAAYFDYWGQGTLVTVS"chain_token="[HEAVY]"species_token="[HUMAN]"infill_range=(98,106)log_likelihood=iglm.log_likelihood(sequence,chain_token,species_token,infill_range=infill_range,)perplexity=math.exp(-log_likelihood)