Mercurial > repos > yating-l > gbtofasta
annotate filter.py @ 5:e195691d3e71 draft
planemo upload commit 10faac43ed16e0bd479f2e9a7d76ccd08b2a5af8-dirty
| author | yating-l |
|---|---|
| date | Thu, 28 Sep 2017 16:25:57 -0400 |
| parents | 894d96efad6d |
| children |
| 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) |
