Difference between revisions of "User:ShawnDouglas/scripts"

From OpenWetWare
Jump to: navigation, search
m
(clean up some old python code)
 
(7 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
*[[/hexgui.py]] - Tk GUI for honeycomb lattice program
 
*[[/hexgui.py]] - Tk GUI for honeycomb lattice program
  
'''Misc'''
+
'''DNA sequence manipulation'''
*replace mac return character ('\r') with unix return ('\n')
 
<pre>
 
cat foo | tr '\r' '\n' > bar
 
mv bar foo
 
</pre>
 
  
*print first n chars of STDIN
+
*reverse complement & remove whitespace
<pre>
 
#!/usr/bin/python
 
  
import string
+
<syntaxhighlight lang="python">
import sys
+
complement = string.maketrans('ACGTacgt','TGCAtgca')
import fileinput
+
def comp(s):
 +
  return s.translate(complement)[::-1]
  
 
def nowhite(s):
 
def nowhite(s):
 
   return ''.join([c for c in s if c in string.letters])
 
   return ''.join([c for c in s if c in string.letters])
  
seq = ''
+
</syntaxhighlight>
  
if len(sys.argv) > 1:
 
  n = int(sys.argv[1])
 
else:
 
  sys.exit("usage: " + sys.argv[0] + " [length]")
 
  
# read in sequence
+
*replace mac return character ('\r') with unix return ('\n')
for line in fileinput.input("-"):
+
<pre>
  seq = seq + nowhite(line)
+
cat foo | tr '\r' '\n' > bar
 
+
mv bar foo
# print last n chars
 
#print seq[-n:]
 
 
 
# print first n chars
 
print seq[:n]
 
 
</pre>
 
</pre>

Latest revision as of 10:56, 12 February 2012

PCR

  • /make-pcr-oligos.py - given target sequence, generate oligos that can be used for PCR assembly of that sequence
  • /random-sequence.py - generate random DNA sequence of specified length
  • /primer.py - given upstream and downstream sense sequence of region to amplify, print out correct primers

Nanostructures

  • /toehold.py - given input sequence generate N-mers orthogonal (to seq and its complement) to be used as toeholds
  • /hexgui.py - Tk GUI for honeycomb lattice program

DNA sequence manipulation

  • reverse complement & remove whitespace

<syntaxhighlight lang="python"> complement = string.maketrans('ACGTacgt','TGCAtgca') def comp(s):

 return s.translate(complement)[::-1]

def nowhite(s):

 return .join([c for c in s if c in string.letters])

</syntaxhighlight>


  • replace mac return character ('\r') with unix return ('\n')
cat foo | tr '\r' '\n' > bar
mv bar foo