<jupyter_start><jupyter_text>Rosetta-stone linking (nplinker version)<jupyter_code>from nplinker.scoring.rosetta import rosetta
ro = rosetta.Rosetta(npl.data_dir, npl.root_dir, npl.dataset_id,ignore_genomic_cache = True)
rhits = ro.run(npl.spectra, npl.bgcs)
print('Rosetta hits: {}'.format(len(rhits)))
for r in rhits:
    print(r)
k = list(ro.bgc_hits.keys())[0]
summary_scores = ro.generate_bgc_summary_scores()
for key,item_list in summary_scores.items():
    for mib,score in item_list.items():
        print(key,'\t',mib,score)
kk = list(summary_scores.keys())
temp = ro.bgc_hits[kk[-2]]['BGC0000644']
tt = temp['individual_hits']
print(tt)
print(temp['all_mibig_genes'])
print(temp['all_bgc_genes'])
import csv
spec_hits = ro.spec_hits
# Write this out as a .tsv file to test the DB loading
with open('carnegie_rosetta_hits.tsv','w') as f:
    writer = csv.writer(f,delimiter='\t')
    heads = ['#Scan#','GNPS_ID','Score']
    writer.writerow(heads)
    for spec,hits in spec_hits.items():
        for hit in hits:
            writer.writerow([spec.spectrum_id, hit[0], hit[1]])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15336322869955157, 'fraction_numerical': 0.009865470852017937, 'mean_word_length': 5.413793103448276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '654378', 'license': 'Apache-2.0', 'n_tokens_mistral': 459, 'n_tokens_neox': 435, 'n_words': 81, 'path': 'notebooks/latest_api_demo.ipynb', 'repo_name': 'louwenjjr/nplinker', 'size': '1115'}