Replace calls to GREP with python equivalent
bud-graziano opened this issue · comments
Andreas Scheck commented
feature request
io.open_rosetta_file
symm = False
files = _gather_file_list( filename, multi )
for file_count, f in enumerate( files ):
if check_symmetry:
cmd = "zgrep SYMMETRY_INFO {} |wc" if f.endswith(".gz") else "grep SYMMETRY_INFO {} |wc"
process = subprocess.Popen(cmd.format(f), stdout=subprocess.PIPE, shell=True)
symm = int(process.communicate()[0].strip().split()[0]) > 0
fd = gzip.open( f ) if f.endswith(".gz") else open( f )
for line in fd:
line = line.decode('utf8') if f.endswith(".gz") else line
if line.strip().split()[0].strip(":") in _headers:
yield line, line.strip().split()[-1] == "description", file_count, symm
fd.close()
Problem description
When checking for symmetry info in silent files, the open_rosetta_file
function calls grep
. This would potentially be faster when calling it just inside python and not spawning a new shell process.
Expected Output
The output remains the same, but the time required for parsing should be less.