Mercurial > repos > yating-l > gbtofasta
annotate filter.py @ 1:b673449d111a draft default tip
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
author | yating-l |
---|---|
date | Mon, 05 Jun 2017 12:50:14 -0400 |
parents | |
children |
rev | line source |
---|---|
1
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
1 import sys |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
2 import argparse |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
3 |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
4 def filter(cds_file, valid_cds_file): |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
5 valid = open(valid_cds_file, 'w') |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
6 with open(cds_file, 'r') as f: |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
7 for line in f: |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
8 if len(line.rstrip().split('\t')) == 2: |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
9 valid.write(line) |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
10 valid.close() |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
11 |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
12 def main(argv): |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
13 parser = argparse.ArgumentParser(description='Filter out records without CDS coordinates') |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
14 parser.add_argument('-f', help='cds file') |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
15 parser.add_argument('-o', help='validated cds file') |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
16 args = parser.parse_args() |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
17 filter(args.f, args.o) |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
18 |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
19 if __name__ == '__main__': |
b673449d111a
planemo upload commit f3fb68f4faf6766eef195b8b36157035ab95e7b1-dirty
yating-l
parents:
diff
changeset
|
20 main(sys.argv) |