<jupyter_start><jupyter_text>V call<jupyter_code>%%time
df1 = pd.DataFrame()
for parq_file in glob.glob('data/adaptive_combined/part.*.parquet'):
    
    data = pd.read_parquet(parq_file,columns=['v_call','repertoire_id']).drop_duplicates().reset_index(drop=True)
    count_vec = CountVectorizer( analyzer='word', tokenizer=lambda x: re.split(r', |or\s', x),
                                ngram_range=(1, 1), max_df=1.0, min_df=1, max_features=None)
    count_train = count_vec.fit(data.v_call)
    bag_of_words = count_vec.transform(data.v_call)
    rr = pd.DataFrame(bag_of_words.toarray(), columns = count_vec.get_feature_names()).drop([''],axis=1)
    cols = rr.columns
    print(parq_file)
    df = pd.concat([data[['repertoire_id']],rr],axis=1)
    df = df.groupby('repertoire_id')[cols].sum().reset_index()
    df1 = pd.concat([df1, df], sort=False).fillna(0)
    cols = df1.drop('repertoire_id',axis=1).columns
    df1 = df1.groupby('repertoire_id')[cols].sum().reset_index()
    del data
    del bag_of_words
    del rr
    del df
df2.to_parquet('data/adaptiveisb1_v_call.parquet')
%%time
data = pd.read_parquet('data/adaptiveisb1_v_call.parquet')
cols = data.drop('repertoire_id',axis=1).columns
data = data.groupby('repertoire_id')[cols].sum().reset_index()
dff = pd.merge(metadata, data, on='repertoire_id', how='inner')
dff.to_parquet('data/v_call.parquet')<jupyter_output><empty_output><jupyter_text>D_call<jupyter_code>%%time
df2 = pd.DataFrame()
for parq_file in glob.glob('data/adaptive_combined/part.*.parquet'):
    
    data = pd.read_parquet(parq_file,columns=['d_call','repertoire_id']).drop_duplicates().reset_index(drop=True)
    count_vec = CountVectorizer( analyzer='word', tokenizer=lambda x: re.split(r', |or\s', x),
                                ngram_range=(1, 1), max_df=1.0, min_df=1, max_features=None)
    data.d_call.fillna(value='None', inplace=True)
    count_train = count_vec.fit(data.d_call)
    bag_of_words = count_vec.transform(data.d_call)
    rr = pd.DataFrame(bag_of_words.toarray(), columns = count_vec.get_feature_names()).drop(['','none'],axis=1)
    cols = rr.columns
    print(parq_file)
    df = pd.concat([data[['repertoire_id']],rr],axis=1)
    df = df.groupby('repertoire_id')[cols].sum().reset_index()
    df2 = pd.concat([df2, df], sort=False).fillna(0)
    cols = df2.drop('repertoire_id',axis=1).columns
    df2 = df2.groupby('repertoire_id')[cols].sum().reset_index()
    del data
    del bag_of_words
    del rr
    del df
df2.to_parquet('data/adaptiveisb2_d_call.parquet')
data = pd.read_parquet('data/adaptiveisb2_d_call.parquet')
cols = data.drop('repertoire_id',axis=1).columns
data = data.groupby('repertoire_id')[cols].sum().reset_index()
dff = pd.merge(metadata, data, on='repertoire_id', how='inner')
dff.to_parquet('data/d_call.parquet')<jupyter_output><empty_output><jupyter_text>J_call<jupyter_code>%%time
df2 = pd.DataFrame()
for parq_file in glob.glob('data/adaptive_combined/part.*.parquet'):
    
    data = pd.read_parquet(parq_file,columns=['j_call','repertoire_id']).drop_duplicates().reset_index(drop=True)
    count_vec = CountVectorizer( analyzer='word', tokenizer=lambda x: re.split(r', |or\s', x),
                                ngram_range=(1, 1), max_df=1.0, min_df=1, max_features=None)
    data.j_call.fillna(value='None', inplace=True)
    count_train = count_vec.fit(data.j_call)
    bag_of_words = count_vec.transform(data.j_call)
    rr = pd.DataFrame(bag_of_words.toarray(), columns = count_vec.get_feature_names()).drop([''],axis=1)
    cols = rr.columns
    print(parq_file)
    df = pd.concat([data[['repertoire_id']],rr],axis=1)
    df = df.groupby('repertoire_id')[cols].sum().reset_index()
    df2 = pd.concat([df2, df], sort=False).fillna(0)
    cols = df2.drop('repertoire_id',axis=1).columns
    df2 = df2.groupby('repertoire_id')[cols].sum().reset_index()
    del data
    del bag_of_words
    del rr
    del df
df2.to_parquet('data/adaptiveisb2_j_call.parquet.parquet')
data = pd.read_parquet('data/adaptiveisb2_j_call.parquet.parquet')
cols = data.drop('repertoire_id',axis=1).columns
data = data.groupby('repertoire_id')[cols].sum().reset_index()
dff = pd.merge(metadata, data, on='repertoire_id', how='inner')
dff.to_parquet('data/j_call.parquet')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16853146853146853, 'fraction_numerical': 0.013286713286713287, 'mean_word_length': 5.035161744022504, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '302388', 'license': 'MIT', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1699, 'n_words': 202, 'path': 'fork-of-precisionfda-immunology-appathon.ipynb', 'repo_name': 'Hstellar/Covid_immunology_appathon_streamlit', 'size': '4290'}