Skip to content

Instantly share code, notes, and snippets.

@JackMaguire
JackMaguire / rename_chains.py
Created October 19, 2023 00:16
rename sabdab chains
import sys
filename = sys.argv[1]
hchain = sys.argv[2]
lchain = sys.argv[3]
achain = sys.argv[4]
with open(filename,'r') as f:
for l in f.readlines():
l = l.strip().rstrip()
@JackMaguire
JackMaguire / parse.sh
Created October 18, 2023 16:05
Parse SabDab
#!/bin/bash
# recently ran `sed -i 's/\t/@/g'`
cat 20231018_0264070_summary.ATsv | awk -F'@' '
BEGIN{
COUNT=1; pdb=COUNT; COUNT=COUNT+1; Hchain=COUNT; COUNT=COUNT+1; Lchain=COUNT; COUNT=COUNT+1; model=COUNT; COUNT=COUNT+1; antigen_chain=COUNT; COUNT=COUNT+1; antigen_type=COUNT; COUNT=COUNT+1; antigen_het_name=COUNT; COUNT=COUNT+1; antigen_name=COUNT; COUNT=COUNT+1; short_header=COUNT; COUNT=COUNT+1; date=COUNT; COUNT=COUNT+1; compound=COUNT; COUNT=COUNT+1; organism=COUNT; COUNT=COUNT+1; heavy_species=COUNT; COUNT=COUNT+1; light_species=COUNT; COUNT=COUNT+1; antigen_species=COUNT; COUNT=COUNT+1; authors=COUNT; COUNT=COUNT+1; resolution=COUNT; COUNT=COUNT+1; method=COUNT; COUNT=COUNT+1; r_free=COUNT; COUNT=COUNT+1; r_factor=COUNT; COUNT=COUNT+1; scfv=COUNT; COUNT=COUNT+1; engineered=COUNT; COUNT=COUNT+1; heavy_subclass=COUNT; COUNT=COUNT+1; light_subclass=COUNT; COUNT=COUNT+1; light_ctype=COUNT; COUNT=COUNT+1; affinity=COUNT; COUNT=COUNT+1; delta_g=COUNT; COUNT=COUNT+1; affinity_method=COUNT; COUNT=COUNT+1;
@JackMaguire
JackMaguire / print_permutations.cc
Last active October 12, 2023 22:24
Graph Permutations
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
using Size = unsigned char;
using Graph = std::array< Size, 6 >;
std::vector< Graph >
remix_all( Graph const & input ){
<!DOCTYPE html>
<html>
<head>
<style>
#game-container {
position: relative;
width: 1000px;
height: 700px;
border: 1px solid #000;
}
@JackMaguire
JackMaguire / chat.md
Last active December 10, 2022 03:15
ChatGPT's paint function

please write javascript code for a simple paint function

Sure, here is an example of JavaScript code for a simple paint function that allows the user to draw on an HTML canvas element:

// Create a canvas element and set its dimensions
var canvas = document.createElement('canvas');
canvas.width = 800;
canvas.height = 600;
@JackMaguire
JackMaguire / prep_for_design.py
Created June 10, 2022 18:30
Relax a crystal structure ahead of design
import sys
import pyrosetta
from pyrosetta import *
from pyrosetta.rosetta import core, protocols
def relax( pose ):
xml = '''<ROSETTASCRIPTS>
<SCOREFXNS>
<ScoreFunction name="sfxn" weights="ref2015_cst"/>
@JackMaguire
JackMaguire / example.xml
Last active March 16, 2022 13:06
timing profile metric
<ROSETTASCRIPTS>
<SIMPLE_METRICS>
<TimingProfileMetric name="t0" custom_type="t0" />
<TimingProfileMetric name="t1" custom_type="t1" />
<TimingProfileMetric name="t2" custom_type="t2" />
<TimingProfileMetric name="t3" custom_type="t3" />
</SIMPLE_METRICS>
<PROTOCOLS>
@JackMaguire
JackMaguire / create_resfiles.cc
Created April 7, 2020 14:07
Computational Methods for Froning, et al.
std::string get_line_for_resid( char chain, core::Size resnum, char aa = 'x' ){
std::stringstream ss;
ss << resnum << " " << chain;
if( aa == 'x' ) ss << " NATAA";
else ss << " PIKAA " << aa;
ss << " USE_INPUT_SC EX 1 LEVEL 1 EX 2 LEVEL 1 EX 3 LEVEL 1 EX 4 LEVEL 1";
return ss.str();
}
void make_resfile( std::string const & filename, core::Size resid, char aa, core::pose::Pose & pose, utility::graph::GraphOP packer_neighbor_graph ){
@JackMaguire
JackMaguire / MarkdownTest.md
Last active November 22, 2019 16:35
Testing Markdown

Description

Rosetta uses 1-indexing for its vector class (utility::vectorL< 1 >, aliased as utility::vector1). We are told in bootcamp that this is only a compile-time slowdown and not a runtime slowdown. I took that with a grain of salt, because surely there must be some slowdown with this implementation:

T &
operator []( index_type const i )
@JackMaguire
JackMaguire / forwarding_example.cpp
Created December 5, 2018 18:33
Example from Sergey on how to use perfect forwarding for edge creation
template< typename... Args >
_Edge * add_edge( uint32_t node1, uint32_t node2 , Args&&... args ) {
debug_assert( ! get_edge_exists( node1, node2 ) );
platform::Size temp = node1 < node2 ? node1 : node2;
node2 = node1 < node2 ? node2 : node1;
node1 = temp;
platform::Size edge_offset = internal_create_new_edge( node1, node2, std::forward<Args>(args)... );
nodes_[ node1 ].internal_add_edge( edge_offset );
nodes_[ node2 ].internal_add_edge( edge_offset );
return internal_get_edge( edge_offset );