-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrandom-dna.py
More file actions
executable file
·30 lines (26 loc) · 1013 Bytes
/
random-dna.py
File metadata and controls
executable file
·30 lines (26 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
# License (GPL) version 3, as described at www.opensource.org.
# Copyright (C)2016 William H. Majoros (martiandna@gmail.com).
#=========================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals, generators, nested_scopes, with_statement)
from builtins import (bytes, dict, int, list, object, range, str, ascii,
chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)
import random
import ProgramName
import sys
from FastaWriter import FastaWriter
if(len(sys.argv)!=3):
exit(ProgramName.get()+" <length> <id>")
L=int(sys.argv[1])
id=sys.argv[2]
seq=""
alphabet=("A","C","G","T")
for i in range(L):
index=int(random.random()*4)
nuc=alphabet[index]
seq+=nuc
writer=FastaWriter()
writer.addToFasta(">"+id,seq,sys.stdout)