File: line_select.py

package info (click to toggle)
python-bx 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,000 kB
  • sloc: python: 17,136; ansic: 2,326; makefile: 24; sh: 8
file content (32 lines) | stat: -rwxr-xr-x 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3

"""
Read a file containing a 0 or 1 on each line (`feature_file`), output
all lines from stdin for which that value was 1

TODO: no need to read the feature_file into memory here, just iterate in
      parallel.

usage: %prog feature_file < ...
"""

import sys


def __main__():
    feature_file = sys.argv[1]

    if len(sys.argv) > 2:
        match = int(sys.argv[2])
    else:
        match = 1

    feature_vector = [int(line) for line in open(feature_file)]

    for index, line in enumerate(sys.stdin):
        if feature_vector[index] == match:
            print(line, end="")


if __name__ == "__main__":
    __main__()