Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #imports for program to work
- #increases functionality with directories
- import glob
- #manipulate different runtime environments
- import sys
- #provides expression patterns (something to do with strings)
- import re
- #working with files and other operating system functions
- import os
- #binary data to python strings/numbers
- import struct
- #access to mathematical functions
- import math
- #html functionality
- import cgi
- #exception handling (catches and reports back)
- import cgitb
- #file writing
- import itertools
- files = ["raw.txt"]
- #=================================================================
- if __name__ == "__main__":
- # Program starts here
- #test program starts
- print "This works."
- #create output file
- outputFile = open('HitOut.txt', "w")
- #save name
- pathname = "raw.txt"
- print pathname
- #read file and save to 'text'
- f = open(pathname, 'r')
- text = f.read()
- f.close()
- #list hits
- hits = []
- #saves rows
- rows = text.splitlines()
- #properties for hits
- x_list = []
- y_list = []
- used = []
- #i is row ID
- i = 0
- #couner for ID
- count = 0
- #loops through all rows
- for row in rows:
- #print i, row
- vals = row.split(' ')
- #j is column ID
- j = 0
- #loops through all values
- for val in vals:
- #if holds val other than 0
- if val != '0':
- #saves location and val
- hit = '#' + repr(count) + '#' + repr(i) + ':' + repr(j) + ':' + repr(val)
- x_list.append(i)
- y_list.append(j)
- used.append('no')
- hits.append(hit)
- count += 1
- #print i,j, val
- #increase coords
- j += 1
- i += 1
- #count for writing all hits
- n = 0
- m = len(hits)
- m += 1
- #loops through all hits and writes
- while (n < m-1):
- outputFile.write(hits[n])
- n += 1
- #close file
- outputFile.close()
- #=================================================================================
- ##Clusters
- #create output file for clusters
- outputFile = open('Cluster_ID.txt', "w")
- #var for loop
- count2 = 0
- count3 = 0
- x = 0
- y = 0
- #clusters
- cluster = []
- identify = []
- new = 0
- #loops for each hit to identify clusters
- while count2 < count + 1
- #check not already in cluster
- if used[count2] = 'no'
- cluster.append(new)
- identify.append(count2)
- #compares all hits against
- while count3 < count + 1
- #skips current selection
- if count3 != count2
- count3 += 1
- count2 += 1
- count3 = 0
Advertisement
Add Comment
Please, Sign In to add comment