#!/usr/bin/python import sys import random def 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 SystemExit if len(sys.argv)==2: if (sys.argv[1][len(sys.argv[1])-4:len(sys.argv[1])]=="help"): print_help() raise SystemExit seq="" 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