<jupyter_start><jupyter_text>Introduction The DCC found some uploaded experiments that lack a biosample ID.<jupyter_code>import pandas
import sys
import os
from pathlib import Path
from IPython.display import HTML

EC = str(Path("~/proj/encoded_client").expanduser())
if EC not in sys.path:
    sys.path.append(EC)
from encoded_client.encoded import ENCODED, get_object_type

server = ENCODED("www.encodeproject.org")
server.load_netrc()
#search = "https://www.encodeproject.org/search/?type=Experiment&replicates.library.biosample.donor.organism.scientific_name!=Homo+sapiens&replicates.library.biosample.donor.organism.scientific_name!=Mus+musculus&internal_status=unreviewed&audit.ERROR.category=missing+biosample"
#graph = server.get_json(search)
#experiment_accessions = []
#for row in graph["@graph"]:
#    experiment_accessions.append(row["accession"])
#experiment_accessions
ENCODE = Path("~/woldlab/ENCODE")
sheet_file = ENCODE / "stranded-23239-23266-left-cortex.xlsx"
mouse_cortex_experiments = pandas.read_excel(sheet_file, sheet_name="Experiment")
mouse_cortex_experiments
#set(mouse_cortex_experiments['accession'].to_list()).symmetric_difference(experiment_accessions)
#set(mouse_cortex_experiments['accession'].to_list()) == set(experiment_accessions)
mouse_cortex_library = pandas.read_excel(sheet_file, sheet_name="Library")
mouse_cortex_library
for i, row in mouse_cortex_library.iterrows():
    library = server.get_json("/library/{}/".format(row['accession']))
    biosample = library.get("biosample")
    if biosample is not None:
        biosample = biosample['accession']
    if biosample != row['biosample']:
        print(row['accession'], biosample, row['biosample'])
        #print(server.patch_json(library["@id"], {"biosample": row['biosample']}))
        #print()
    
for i, row in mouse_cortex_experiments.iterrows():
    print(server.prepare_url('/experiment/{}/'.format(row['accession'])))
mouse_cortex_replicates = pandas.read_excel(sheet_file, sheet_name="Replicate")
report = ["<table><tr><td>Exp Desc</td><td>Bio Desc</td><td>Age</td><td>Age Units</td></tr>"]
for i, row in mouse_cortex_replicates.iterrows():
    replicate = server.get_json(row['uuid'])
    experiment = replicate['experiment']
    biosample_accession = replicate['library']['biosample']['accession']
    biosample = server.get_json('/biosample/{}/'.format(biosample_accession))
    report.append("<tr><td>{}</td><td>{}</td><td>{}</td><td>{}</td></tr>".format(
        experiment['description'], 
        biosample['description'], 
        biosample['model_organism_age'], 
        biosample['model_organism_age_units']
    ))
report.append("</table>")
HTML("\n".join(report))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15812753409509767, 'fraction_numerical': 0.003685956505713233, 'mean_word_length': 6.538888888888889, 'pattern_counts': {'":': 1, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, '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': '184473', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 942, 'n_tokens_neox': 907, 'n_words': 128, 'path': 'diagnose-missing-biosamples.ipynb', 'repo_name': 'detrout/encode4-curation', 'size': '2713'}