annotate convertply.py @ 19:f3d9bb18110a draft default tip

Uploaded
author mb2013
date Tue, 20 May 2014 03:30:07 -0400
parents c2761ec99e82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
1 #Converter for ply to ply in Galaxy.
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
2 #MB
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
3 #last update: 9-5-2014
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
4
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
5 #This programm extracts the enters of the header,
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
6 #caused by importing it to Galaxy.
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
7
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
8 import sys
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
9
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
10 # removing all the empty lines in the ply file
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
11
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
12 # Function main
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
13 def main():
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
14 name_file_ply = sys.argv[1] # name of the ply file
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
15 name_output = sys.argv[2] # name of the output file
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
16
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
17 # open the input and output file
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
18 file_ply = open(name_file_ply)
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
19 output = open(str(name_output), 'w')
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
20
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
21 lines = file_ply.readlines()
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
22 file_ply.close()
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
23
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
24 file_ply = open(name_file_ply) # re-open the file
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
25 remove_empty_lines(lines, name_file_ply, output)
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
26
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
27 # Function remove empty line
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
28 def remove_empty_lines(lines,name_file_ply, output):
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
29 file_ply = open(name_file_ply)
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
30 for x in range(0,len(lines)):
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
31 line = file_ply.readline().strip()
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
32 line2 = line.strip().split()
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
33
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
34 #writing all the correct lines to the ouputfile
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
35 if len(line2) != 0:
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
36 output.write('%s\n'%(line))
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
37
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
38 output.close()
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
39
c2761ec99e82 Uploaded
mb2013
parents:
diff changeset
40 main()