annotate filter.py @ 7:57e30c6c0aa4 draft default tip

planemo upload commit 418d3a27a673cef3f350e514fb6101fcde009b9d
author yating-l
date Mon, 06 Nov 2017 15:45:26 -0500
parents 894d96efad6d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
1 import sys
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
2 import argparse
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
3
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
4 def filter(cds_file, valid_cds_file):
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
5 valid = open(valid_cds_file, 'w')
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
6 with open(cds_file, 'r') as f:
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
7 for line in f:
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
8 if len(line.rstrip().split('\t')) == 2:
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
9 valid.write(line)
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
10 valid.close()
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
11
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
12 def main(argv):
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
13 parser = argparse.ArgumentParser(description='Filter out records without CDS coordinates')
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
14 parser.add_argument('-f', help='cds file')
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
15 parser.add_argument('-o', help='validated cds file')
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
16 args = parser.parse_args()
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
17 filter(args.f, args.o)
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
18
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
19 if __name__ == '__main__':
894d96efad6d planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff changeset
20 main(sys.argv)