#!/usr/bin/python
import os
import random
import re
 
# Constants and global members:
TARGETFILE = "TtLSU"
LIMIT = 8822
numbers = [];

###
# Generate a bunch of test data values and insert into an array 
# (list). Don't worry about putting it into a file. Make sure
# to cast to a string as this will make the injection phase
# trivial (easy).
###
for i in xrange(LIMIT):
    numbers.insert(i, str(random.randint(-3, 3)))

###
# Main pdb data file:
###
fstream    = open(TARGETFILE+".pdb", "r")

###
# Temp file for caching injected values:
###
fstreamtmp = open(TARGETFILE+".pdb.tmp", "w")

###
# Convert PDB into a space delimeted format then split
# on each space. Next inject each number from our list into 
# each tuple (row) for the 10th column.
###
i = 0
for line in fstream:
    line = re.sub(r' +', r' ', line.rstrip())    
    columns = line.rstrip().split(' ');
    columns[9] = numbers[i]
    i += 1
    # Build our string:
    tuple = ""
    for word in columns:
        tuple += word + " "

    # Uncomment line below to print each tuple (row) to STDOUT for testing.
    # print tuple.rstrip()

    # Dump each tuple (row) into the tmp file.
    # The rstrip removes the extra white space from the end.
    fstreamtmp.write(str(tuple.rstrip()) + "\n")

fstream.close()
fstreamtmp.close()

# Superimpose (write over) contents of original pdb with pdb.tmp file:
os.rename(TARGETFILE+".pdb.tmp", TARGETFILE+".pdb")

731151a61507a2c7224162e7fae7aec72f82ea5e
<mask token>

<mask token>
for i in xrange(LIMIT):
    numbers.insert(i, str(random.randint(-3, 3)))
<mask token>
for line in fstream:
    line = re.sub(' +', ' ', line.rstrip())
    columns = line.rstrip().split(' ')
    columns[9] = numbers[i]
    i += 1
    tuple = ''
    for word in columns:
        tuple += word + ' '
    fstreamtmp.write(str(tuple.rstrip()) + '\n')
fstream.close()
fstreamtmp.close()
os.rename(TARGETFILE + '.pdb.tmp', TARGETFILE + '.pdb')

<mask token>
TARGETFILE = 'TtLSU'
LIMIT = 8822
numbers = []
for i in xrange(LIMIT):
    numbers.insert(i, str(random.randint(-3, 3)))
fstream = open(TARGETFILE + '.pdb', 'r')
fstreamtmp = open(TARGETFILE + '.pdb.tmp', 'w')
i = 0
for line in fstream:
    line = re.sub(' +', ' ', line.rstrip())
    columns = line.rstrip().split(' ')
    columns[9] = numbers[i]
    i += 1
    tuple = ''
    for word in columns:
        tuple += word + ' '
    fstreamtmp.write(str(tuple.rstrip()) + '\n')
fstream.close()
fstreamtmp.close()
os.rename(TARGETFILE + '.pdb.tmp', TARGETFILE + '.pdb')

import os
import random
import re
TARGETFILE = 'TtLSU'
LIMIT = 8822
numbers = []
for i in xrange(LIMIT):
    numbers.insert(i, str(random.randint(-3, 3)))
fstream = open(TARGETFILE + '.pdb', 'r')
fstreamtmp = open(TARGETFILE + '.pdb.tmp', 'w')
i = 0
for line in fstream:
    line = re.sub(' +', ' ', line.rstrip())
    columns = line.rstrip().split(' ')
    columns[9] = numbers[i]
    i += 1
    tuple = ''
    for word in columns:
        tuple += word + ' '
    fstreamtmp.write(str(tuple.rstrip()) + '\n')
fstream.close()
fstreamtmp.close()
os.rename(TARGETFILE + '.pdb.tmp', TARGETFILE + '.pdb')

#!/usr/bin/python
import os
import random
import re
 
# Constants and global members:
TARGETFILE = "TtLSU"
LIMIT = 8822
numbers = [];

###
# Generate a bunch of test data values and insert into an array 
# (list). Don't worry about putting it into a file. Make sure
# to cast to a string as this will make the injection phase
# trivial (easy).
###
for i in xrange(LIMIT):
    numbers.insert(i, str(random.randint(-3, 3)))

###
# Main pdb data file:
###
fstream    = open(TARGETFILE+".pdb", "r")

###
# Temp file for caching injected values:
###
fstreamtmp = open(TARGETFILE+".pdb.tmp", "w")

###
# Convert PDB into a space delimeted format then split
# on each space. Next inject each number from our list into 
# each tuple (row) for the 10th column.
###
i = 0
for line in fstream:
    line = re.sub(r' +', r' ', line.rstrip())    
    columns = line.rstrip().split(' ');
    columns[9] = numbers[i]
    i += 1
    # Build our string:
    tuple = ""
    for word in columns:
        tuple += word + " "

    # Uncomment line below to print each tuple (row) to STDOUT for testing.
    # print tuple.rstrip()

    # Dump each tuple (row) into the tmp file.
    # The rstrip removes the extra white space from the end.
    fstreamtmp.write(str(tuple.rstrip()) + "\n")

fstream.close()
fstreamtmp.close()

# Superimpose (write over) contents of original pdb with pdb.tmp file:
os.rename(TARGETFILE+".pdb.tmp", TARGETFILE+".pdb")
