<jupyter_start><jupyter_text>Mutated Spike Proteins using Recursive Decision Forests (Qnets)---https://zed.uchicago.edu- <NAME> <EMAIL>- <NAME><jupyter_code>import pandas as pd
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.Alphabet import generic_dna
from Bio import SeqIO
%matplotlib inline
import pylab as plt
plt.style.use('ggplot')
# read in data
rfaa=pd.read_csv('simulated_sequences_data_standard_aa.csv')<jupyter_output><empty_output><jupyter_text>Two Notions of Sequence Similarity---+ Edit distance is the classical "mutation distance" between sequences+ Q-distance is the distance computed using emergent evolutionary constraints These two metrics are correlated but distinct. The latter is biologicaly *more meraningful*, since it captures which mutations can actually happen in the wild population, and factors this information in in a rigorous probabilistic setting<jupyter_code>plt.figure(figsize=[10,6])
QTH=.01
ax=rfaa[rfaa.qdistance<QTH].plot.scatter(ax=plt.gca(),x='ldistance',y='qdistance',cmap='Spectral_r',
                                          c=rfaa[rfaa.qdistance<QTH].step.values,alpha=0.25)
ax.set_ylim(-0.0005,QTH+0.0005)
axx=plt.gcf().get_axes()
axx[1].set_ylabel('generation [steps]')
ax.set_xlabel('Edit Distance')
ax.set_ylabel('Q Distance');<jupyter_output><empty_output><jupyter_text>Simulating Viable Evolutionary Trajectories---The Q-net models allow us to predict how a given strain in the wild willchange over time, i.e., track diffusion in the strain space.+ We need to validate that the predicted sequence variations are biologically meaningful.We select mutated samples which have high edit distance, but a small q-distance. The hypothesis is that since the Q-net captures the "rules of evolution", these are still viable sequences, and will fold correctly and preserve function<jupyter_code># sampling steps as we simulate diffusion in the strain space
STEPS=rfaa.step.value_counts().sort_index().index.values
STEPS
NUM=500
QTH=0.01
DF=pd.concat([rfaa[(rfaa.qdistance<QTH) 
                   & (rfaa.step==i)].sort_values('qdistance').head(NUM).sort_values('ldistance',ascending=False).head(1)
           for i in STEPS])
DF=DF.set_index('step')
# plot Edit distance vs scaled Q-distance
DF.ldistance.plot(style='-ro',ms=10)
(60000*DF.qdistance).plot(style='-ko',ms=10)<jupyter_output><empty_output><jupyter_text>Predicted Sequences ---+ ldistance: Edit distance (no of mutations from the originating strain)+ accession: Accession number of originating strain+ file_name: fasta file in the same directory<jupyter_code>DF<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1046200840015273, 'fraction_numerical': 0.013363879343260786, 'mean_word_length': 5.752577319587629, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 20, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '92640', 'license': 'MIT', 'n_tokens_mistral': 844, 'n_tokens_neox': 784, 'n_words': 236, 'path': 'predicted_sequences.ipynb', 'repo_name': 'zeroknowledgediscovery/qexp', 'size': '2644'}