This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' search or blast pdb ''' | |
| import SOAPpy, getopt, sys, os, shutil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' format the leading spaces and tabs | |
| Main functions: | |
| * tab2sp(): change leading tabs to spaces | |
| * reindent(): main function, reformat the leading indents | |
| reindentf(): wrapper for reindent, accepts a file | |
| * guessindent(): guess the indent size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| add spaces for C source code | |
| the main function is addspacef() | |
| Example 1: | |
| if(a>b&&a>3)c=d; | |
| --> if (a > b && a > 3) c = d; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' remove trailing spaces in a text file ''' | |
| import os, sys, getopt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import math | |
| class scifmt: | |
| def __init__(me, x, err = 0): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import * | |
| def getdigits(n, p): | |
| ''' write n as a base-p number | |
| the least significant digit goes first | |
| ''' | |
| arr = [] | |
| while n: | |
| arr += [n % p, ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' Markov-chain text generator ''' | |
| import random, re, sys | |
| from collections import deque | |
| order = 2 | |
| fnin = "advshl.txt" # input text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #if defined(Macintosh) || defined(__APPLE__) | |
| /* to compile: gcc -framework OpenGL -framework GLUT lj3.c */ | |
| #include <GLUT/glut.h> | |
| #else | |
| #include <GL/glut.h> | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Numerically solve the 3D PY or HNC equation | |
| * gcc -O3 inteq.c -lfftw3 -lm | |
| * For the PY version | |
| * ./a.out > a.dat | |
| * For the HNC version | |
| * ./a.out HNC > b.dat | |
| * In Gnuplot: | |
| * plot "a.dat" u 1:3 w l t "g(r), PY", \ | |
| * "b.dat" u 1:3 w l t "g(r), HNC" | |
| * */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* renormalization of the quadratic map | |
| cf. B-L Hao, Elementary Symbolic Dynamics, Sec. 2.7.2 Table 2.3 and Sec. 3.4.2-3.4.3 Table 3.4 *) | |
| n = 3; (* number of terms *) | |
| z = 2; (* map is f = 1 + A1 x^z + A2 x^(2z) + ... *) | |
| niter = 3; (* 2 for period-doubling, 3 for -trippling *) | |
| A = Table[ToExpression[ToString["A"] <> ToString[k]], {k, 1, n}]; (* coefficients *) | |
| f[x_] := 1 + A.Table[x^(z k), {k, 1, n}]; (* the map *) | |
| del = f[a x] - a Nest[f, x, niter]; (* renormalization equation, del should be 0 *) | |
| eqs = Table[Coefficient[del, x, j z], {j, 0, n}]; (* the coefficients of the x^(j z) term *) | |
| init = Append[ (* initial guess for A1, A2, ..., and a *) |