<commit_before><html>
<head>
	<title>Explain SAM Flags</title>
	<script type="text/javascript">
		lstFlags = [["read paired", 0x1],
			    ["read mapped in proper pair", 0x2],
			    ["read unmapped", 0x4],
			    ["mate unmapped", 0x8],
			    ["read reverse strand", 0x10],
			    ["mate reverse strand", 0x20],
			    ["first in pair", 0x40],
			    ["second in pair", 0x80],
			    ["not primary alignment", 0x100],
			    ["read fails platform/vendor quality checks", 0x200],
			    ["read is PCR or optical duplicate", 0x400],
			    ["supplementary alignment", 0x800]];

		function explainFlags() {
			var flagValue = parseInt(document.getElementById('tb').value); //returns 0 or NaN if can't parse
			var summary = "";
			for(var i = 0; i < lstFlags.length; i++) {
				var checkbox = document.getElementById('cb' + i)
				if(lstFlags[i][1] & flagValue) {
					summary  += " &nbsp; &nbsp; " + lstFlags[i][0] + "<br>";
					checkbox.checked = true;
				} else {
					checkbox.checked = false;
				}
			}

			document.getElementById('summary').innerHTML = summary;
		}

		function checkboxClicked() {
			//compute the new flag value
			var newFlagValue = 0;
			for(var i = 0; i < lstFlags.length; i++) {
				var checkBox = document.getElementById('cb' + i);
				if(checkBox.checked) {
					newFlagValue |= lstFlags[i][1];
				}
			}
			var textbox = document.getElementById('tb');
			textbox.value = newFlagValue;
			explainFlags();
		}
	</script>

	<noscript>This page requires JavaScript. Please enable it in your browser settings.</noscript>
</head>
<body>

This utility explains SAM flags in plain English. <br>
<br>

<form onSubmit="explainFlags(); return false;">
Flag: &nbsp;
<input id="tb" type=text size=10 /> &nbsp; &nbsp; &nbsp;
<input type=submit value="Explain" /><br>
<br>
Explanation:<br>
<script type="text/javascript">
for(var i = 0; i < lstFlags.length; i++) {
	document.write("<input type=checkbox name=cb" + i + " id='cb" + i + "' onclick='checkboxClicked();'> &nbsp; " +lstFlags[i][0] + "</input><br>");
}
</script>
<br>
Summary:<br>
<div id="summary">

</form>

</body>
</html><commit_msg>Added a button  to the explain-flags.html page. This button switches the flag from the flag of a read, to that of its mate (as much as can be infered).<commit_after><html>
<head>
    <title>Explain SAM Flags</title>
    <script type="text/javascript">
		lstFlags = [["read paired", 0x1],
			    ["read mapped in proper pair", 0x2],
			    ["read unmapped", 0x4],
			    ["mate unmapped", 0x8],
			    ["read reverse strand", 0x10],
			    ["mate reverse strand", 0x20],
			    ["first in pair", 0x40],
			    ["second in pair", 0x80],
			    ["not primary alignment", 0x100],
			    ["read fails platform/vendor quality checks", 0x200],
			    ["read is PCR or optical duplicate", 0x400],
			    ["supplementary alignment", 0x800]];

		function explainFlags() {
			var flagValue = parseInt(document.getElementById('tb').value); //returns 0 or NaN if can't parse
			var summary = "";
			for(var i = 0; i < lstFlags.length; i++) {
				var checkbox = document.getElementById('cb' + i)
				if(lstFlags[i][1] & flagValue) {
					summary  += " &nbsp; &nbsp; " + lstFlags[i][0] + "<br>";
					checkbox.checked = true;
				} else {
					checkbox.checked = false;
				}
			}

			document.getElementById('summary').innerHTML = summary;
		}

		function checkboxClicked() {
			//compute the new flag value
			var newFlagValue = 0;
			for(var i = 0; i < lstFlags.length; i++) {
				var checkBox = document.getElementById('cb' + i);
				if(checkBox.checked) {
					newFlagValue |= lstFlags[i][1];
				}
			}
			var textbox = document.getElementById('tb');
			textbox.value = newFlagValue;
			explainFlags();
		}

		function switchToMate() {
            swaps = [[2,3],[4,5],[6,7]]
            for( var i = 0 ; i<swaps.length ; i++){
                swap1=swaps[i][0]
                swap2=swaps[i][1]

                val1 = document.getElementById('cb' + swap1).checked;
                val2 = document.getElementById('cb' + swap2).checked;

                document.getElementById('cb' + swap1).checked=val2
                document.getElementById('cb' + swap2).checked=val1

                checkboxClicked()
            }
		}

    </script>

    <noscript>This page requires JavaScript. Please enable it in your browser settings.</noscript>
</head>
<body>

This utility explains SAM flags in plain English. <br>
It also allows switching easily from a read to its mate.
<br>
<p>

<form onSubmit="explainFlags(); return false;" action="">
Flag: &nbsp;
<input id="tb" type=text size=10 /> &nbsp; &nbsp; &nbsp;
<input type=submit value="Explain" /><br>
<br>
<div id="button" align="left">
    <button onclick="switchToMate()">Switch to mate</button>
</div>
<p>

    Explanation:<br>
<script type="text/javascript">
for(var i = 0; i < lstFlags.length; i++) {
	document.write("<input type=checkbox name=cb" + i + " id='cb" + i + "' onclick='checkboxClicked();'> &nbsp; " +lstFlags[i][0] + "</input><br>");
}
</script>
<br>
Summary:<br>
<div id="summary">

</div>
</form>
</body>
</html>
{'fraction_non_alphanumeric': 0.16791191506095163, 'fraction_numerical': 0.022217852929610697, 'mean_word_length': 3.179950698438784, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 70, '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}}
{'dir': 'git-commits-cleaned', 'id': '7430792', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1641, 'n_words': 463}