<commit_before><commit_msg>script to partition out a subset of ClinVar XML for testing<commit_after>#! /bin/bash

# extract ClinVarSets containing specific RCV
# not at all efficent, but does not need to be.
# give a list of RCV identifiers
#
# Usage:
# ClinVarXML_Subset.sh	 [<rcvlist> <cvxml>] > ClinVarTestSet.xml
# e.g.
# ./scripts/ClinVarXML_Subset.sh | gzip > raw/clinvarxml_alpha/ClinVarTestSet.xml.gz

# Defaults if not given
RPTH='raw/clinvarxml_alpha'
TEST=${1:-"${RPTH}/CV_test_RCV.txt"}
CXML=${2:-"${RPTH}/ClinVarFullRelease_00-latest.xml.gz"}

CVSET='ReleaseSet/ClinVarSet'
RCV='ReferenceClinVarAssertion/ClinVarAccession/@Acc'

### header
if [ 'gz' == "${CXML##*.}" ] ; then
    zcat "${CXML}" | head -3
else
    head -3 "${CXML}"
fi

### body
for rcv in `< "${TEST}"`; do
    xmlstarlet sel -t -c "${CVSET}[${RCV}=\"${rcv}\"]" -n "${CXML}"
done


### footer
if [ 'gz' == "${CXML##*.}" ] ; then
    zcat "${CXML}" | tail -2
else
    tail -2  "${CXML}"
fi

{'fraction_non_alphanumeric': 0.19298245614035087, 'fraction_numerical': 0.008255933952528379, 'mean_word_length': 4.18716577540107, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, '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}}
{'dir': 'git-commits-cleaned', 'id': '7193525', 'n_tokens_mistral': 392, 'n_tokens_neox': 380, 'n_words': 93}