Skip to content

Instantly share code, notes, and snippets.

View GeauxEric's full-sized avatar

GeauxEric GeauxEric

  • Nvidia
  • CA USA
  • 08:06 (UTC -07:00)
View GitHub Profile
@GeauxEric
GeauxEric / impute
Created June 4, 2015 05:27
Impute missing value
# see http://stackoverflow.com/questions/25239958/impute-categorical-missing-values-in-scikit-learn/25562948#25562948
import pandas as pd
import numpy as np
from sklearn.base import TransformerMixin
class DataFrameImputer(TransformerMixin):
def __init__(self):
@GeauxEric
GeauxEric / readReport.py
Last active August 29, 2015 14:23
read the report of GeauxDock
import re
def readReport(fn):
"""
read the report file generated by running docking and extract the
"""
ifn = fn
lines = open(ifn, 'r').readlines()
pattern = 'temp #'
temps = [float(line.split()[-1]) for line in lines if re.match(pattern, line)]
@GeauxEric
GeauxEric / submit.pbs
Created June 23, 2015 18:15
submit pbs job
#!/bin/bash
#PBS -q workq
#PBS -j oe
## user specified
#PBS -l nodes=1:ppn=16
#PBS -l walltime=72:00:00
#send an email after job aborts or ends
#PBS -M yding8@lsu.edu
@GeauxEric
GeauxEric / stream.scm
Last active September 5, 2015 07:03
3.53 ~ 3.54 sicp
(define (add-stream s1 s2)
(stream-map + s1 s2))
(define s (cons-stream 1 (add-stream s s)))
(stream-ref s 2)
(stream-ref s 5)
(define (mul-stream s1 s2)
(stream-map * s1 s2))
@GeauxEric
GeauxEric / check_output.cpp
Last active October 2, 2015 18:05
a cpp snippets like the subprocess32.check_output in python
#include <string>
#include <iostream>
#include <stdio.h>
/**
* \file check_output.cpp
* \brief a cpp function just like the subprocess32.check_output() in python
*
* see http://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c
*
@GeauxEric
GeauxEric / pdb_line_regx.cpp
Created October 7, 2015 04:54
regular expression in c++ to match a typical ATOM line in pdb format
#include <regex>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string line {"ATOM 1 N ILE C 1 31.399 11.874 36.182 1.00 0.00"};
@GeauxEric
GeauxEric / uglyNum2.py
Last active November 13, 2015 22:02
Write a program to find the n-th ugly number
# https://leetcode.com/problems/ugly-number-ii/
class Solution(object):
def nthUglyNumber(self, n):
"""
:type n: int
:rtype: int
"""
if n < 5:
return n
@GeauxEric
GeauxEric / dockedpose.py
Last active February 7, 2022 03:46 — forked from baoilleach/dockedpose.py
Using Open Babel to calculate the symmetry-corrected RMSD of a docked pose from a crystal structure
import math
import pybel
def squared_distance(coordsA, coordsB):
"""Find the squared distance between two 3-tuples"""
sqrdist = sum((a - b)**2 for a, b in zip(coordsA, coordsB))
return sqrdist
@GeauxEric
GeauxEric / regx_find_float.py
Created February 19, 2016 16:54
regular expression to find all float number in a string
s = u'(-1.234, 12]'
import re
print re.findall(r'[+-]?\d+\.*\d*', s)
@GeauxEric
GeauxEric / ipython_notebook_toggle_codecell.py
Created February 19, 2016 19:22
toggle the code cell in the html output of ipython notebook
<!-- thanks to https://github.com/Saynah -->
<script>
var code_show=true; //true -> hide code at first
function code_toggle() {
$('div.prompt').hide(); // always hide prompt
if (code_show){