All pastes #790171 Raw Edit

Brandon Barker / Random BioSeq G

public python v1 · immutable
#790171 ·published 2007-11-20 03:51 UTC
rendered paste body
#!/usr/bin/pythonimport sysimport randomdef print_help():  print "syntax is: randseq2.py {protX,prot,dna,dnan} length"dna = dict({0:'A',1:'G',2:'C',3:'T'});dnan = dict({0:'A',1:'G',2:'C',3:'T',4:'N'})prot = dict({0:'G',1:'A',2:'L',3:'M',4:'F',5:'W',6:'K',7:'Q',8:'E',9:'S',10:'P',11:'V',12:'I',13:'C',14:'Y',15:'H',16:'R',17:'N',18:'D',19:'T'})protX = dict({0:'G',1:'A',2:'L',3:'M',4:'F',5:'W',6:'K',7:'Q',8:'E',9:'S',10:'P',11:'V',12:'I',13:'C',14:'Y',15:'H',16:'R',17:'N',18:'D',19:'T',20:'X'})if len(sys.argv)==1:  print_help()  raise SystemExitif len(sys.argv)==2:  if (sys.argv[1][len(sys.argv[1])-4:len(sys.argv[1])]=="help"):    print_help()    raise SystemExitseq=""if sys.argv[1]=="dna":  ldict=dna;if sys.argv[1]=="dnan":  ldict=dnan;if sys.argv[1]=="prot":  ldict=prot;if sys.argv[1]=="protX":  ldict=protX;for i in range (1,int(sys.argv[2])):  seq += ldict[random.randint(0,len(ldict)-1)]print seq