User:ShawnDouglas/scripts: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 23: Line 23:


*print first n chars of STDIN
*print first n chars of STDIN
<pre>
<syntax type="python">
#!/usr/bin/python
#!/usr/bin/python


Line 51: Line 51:
# print first n chars
# print first n chars
print seq[:n]
print seq[:n]
</pre>
</syntax>


*Check for restriction site
*Check for restriction site
<pre>
<syntax type="python">
##
##
# return True if s DOES contain any restriction sites
# return True if s DOES contain any restriction sites
Line 101: Line 101:


   return result
   return result
</pre>
</syntax>

Revision as of 17:14, 8 April 2007

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

Misc

  • reverse complement
complement = string.maketrans('ACGTacgt','TGCAtgca')
def comp(s):
  return s.translate(complement)[::-1]
  • replace mac return character ('\r') with unix return ('\n')
cat foo | tr '\r' '\n' > bar
mv bar foo
  • print first n chars of STDIN

<syntax type="python">

  1. !/usr/bin/python

import string import sys import fileinput

def nowhite(s):

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

seq =

if len(sys.argv) > 1:

 n = int(sys.argv[1])

else:

 sys.exit("usage: " + sys.argv[0] + " [length]")
  1. read in sequence

for line in fileinput.input("-"):

 seq = seq + nowhite(line)
  1. seq = seq[offset:] + seq[:offset] # wrap around first offset bases
  1. print last n chars
  2. print seq[-n:]
  1. print first n chars

print seq[:n] </syntax>

  • Check for restriction site

<syntax type="python">

  1. return True if s DOES contain any restriction sites
  2. return False if s DOES NOT contain any restriction sites

def hasresite(s):

 BamHI = 'ggatcc'
 EcoRI = 'gaattc'
 FokI = 'ggatg'
 HindIII = 'aagctt'
 BglII = 'agatct'
 XbaI = 'tctaga'
 XhoI = 'ctcgag'
 BbvCIA = 'cctcagc'
 BbvCIB = comp(BbvCIA)
 result = False
 if s.count(BamHI) > 0:
   #print 'BamHI found'
   result = True
 elif s.count(EcoRI) > 0:
   #print 'EcoRI found'
   result = True
 elif s.count(FokI) > 0:
   #print 'FokI found'
   result = True
 elif s.count(HindIII) > 0:
   #print 'HindIII found'
   result = True
 elif s.count(BglII) > 0:
   #print 'BglII found'
   result = True
 elif s.count(XbaI) > 0:
   #print 'XbaI found'
   result = True
 elif s.count(XhoI) > 0:
   #print 'XhoI found'
   result = True
 elif s.count(BbvCIA) > 0: 
   #print 'BbvCI.IA found'
   result = True
 elif s.count(BbvCIB) > 0:
   #print 'BbvCI.IB found'
   result = True
 return result

</syntax>