/usr/lib/python2.7/dist-packages/cogent/parse/kegg_pos.py is in python-cogent 1.9-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 33 34 35 36 37 38 39 40 41 42 43 44 | #!/usr/bin/env python
__author__ = "Jesse Zaneveld"
__copyright__ = "Copyright 2007-2016, The Cogent Project"
__credits__ = ["Jesse Zaneveld", "Rob Knight"]
__license__ = "GPL"
__version__ = "1.9"
__maintainer__ = "Jesse Zaneveld"
__email__ = "zaneveld@gmail.com"
__status__ = "Release"
"""
Parser for kegg .pos files
Currently this is quite bare-bones, and primarily useful
for associating the species name with the results, which is
essential if combining multiple .pos files into a single
database.
"""
# Pos file parsers
def parse_pos_file(fname):
"""Opens fname, extracts pos fields and prepends filename"""
curr_file = open(fname,"U")
for line in parse_pos_lines(curr_file,fname):
yield line
def parse_pos_lines(lines, file_name):
"""Parse lines from a KEGG .pos file, yielding tab-
delimited strings
file name -- the file name, for deriving the
species for the pos file (this is not available within
the pos file, but important for mapping to other KEGG
data)
"""
species_name = file_name.split('/')[-1].rsplit('.',1)[0]
for line in lines:
yield species_name + '\t' + line[:-1] + "\n"
if __name__ == '__main__':
from sys import argv
filename = argv[1]
for result_line in parse_pos_file(filename):
print result_line.strip()
|