-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust fhandle names to files and iterables.
- Loading branch information
Showing
9 changed files
with
409 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ | |
>>> help(MODULE.run) | ||
""" | ||
|
||
|
||
__all__ = [ | ||
'pdb_b', | ||
'pdb_chainbows', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import os | ||
import sys | ||
|
||
|
||
__author__ = "Joao Rodrigues" | ||
__email__ = "[email protected]" | ||
|
||
|
@@ -71,7 +72,7 @@ def check_input(args): | |
return fh | ||
|
||
|
||
def run(fhandle): | ||
def run(fhandle, outname=None): | ||
""" | ||
Split the PDB into its different chains. | ||
|
@@ -81,9 +82,21 @@ def run(fhandle): | |
Parameters | ||
---------- | ||
fhandle : an iterable giving the PDB file line-by-line | ||
outname : str | ||
The base name of the output files. If None is given, tries to | ||
extract a name from the `.name` attribute of `fhandler`. If | ||
`fhandler` has no attribute name, assigns `splitchains`. | ||
""" | ||
fname_root = fhandle.name[:-4] if fhandle.name != '<stdin>' else 'output' | ||
basename = os.path.basename(fname_root) | ||
_defname = 'splitchains' | ||
if outname is None: | ||
try: | ||
fn = fhandle.name | ||
outname = fn[:-4] if fn != '<stdin>' else _defname | ||
except AttributeError: | ||
outname = _defname | ||
|
||
basename = os.path.basename(outname) | ||
|
||
chain_data = {} # {chain_id: lines} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import os | ||
import sys | ||
|
||
|
||
__author__ = "Joao Rodrigues" | ||
__email__ = "[email protected]" | ||
|
||
|
@@ -71,7 +72,7 @@ def check_input(args): | |
return fh | ||
|
||
|
||
def run(fhandle): | ||
def run(fhandle, outname=None): | ||
""" | ||
Split PDB into MODELS. | ||
|
@@ -81,9 +82,21 @@ def run(fhandle): | |
Parameters | ||
---------- | ||
fhandle : a line-by-line iterator of the original PDB file. | ||
outname : str | ||
The base name of the output files. If None is given, tries to | ||
extract a name from the `.name` attribute of `fhandler`. If | ||
`fhandler` has no attribute name, assigns `splitmodels`. | ||
""" | ||
fname_root = fhandle.name[:-4] if fhandle.name != '<stdin>' else 'pdbfile' | ||
basename = os.path.basename(fname_root) | ||
_defname = 'splitmodels' | ||
if outname is None: | ||
try: | ||
fn = fhandle.name | ||
outname = fn[:-4] if fn != '<stdin>' else _defname | ||
except AttributeError: | ||
outname = _defname | ||
|
||
basename = os.path.basename(outname) | ||
|
||
model_lines = [] | ||
records = ('ATOM', 'HETATM', 'ANISOU', 'TER') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import os | ||
import sys | ||
|
||
|
||
__author__ = "Joao Rodrigues" | ||
__email__ = "[email protected]" | ||
|
||
|
@@ -71,7 +72,7 @@ def check_input(args): | |
return fh | ||
|
||
|
||
def run(fhandle): | ||
def run(fhandle, outname=None): | ||
""" | ||
Split PDB into segments. | ||
|
@@ -81,9 +82,21 @@ def run(fhandle): | |
Parameters | ||
---------- | ||
fhandle : a line-by-line iterator of the original PDB file. | ||
outname : str | ||
The base name of the output files. If None is given, tries to | ||
extract a name from the `.name` attribute of `fhandler`. If | ||
`fhandler` has no attribute name, assigns `splitsegs`. | ||
""" | ||
fname_root = fhandle.name[:-4] if fhandle.name != '<stdin>' else 'output' | ||
basename = os.path.basename(fname_root) | ||
_defname = 'splitsegs' | ||
if outname is None: | ||
try: | ||
fn = fhandle.name | ||
outname = fn[:-4] if fn != '<stdin>' else _defname | ||
except AttributeError: | ||
outname = _defname | ||
|
||
basename = os.path.basename(outname) | ||
|
||
segment_data = {} # {segment_id: lines} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
import os | ||
import sys | ||
|
||
|
||
__author__ = "Joao Rodrigues" | ||
__email__ = "[email protected]" | ||
|
||
|
@@ -80,7 +81,7 @@ def pad_line(line): | |
return line[:81] # 80 + newline character | ||
|
||
|
||
def run(fhandle): | ||
def run(fhandle, outname=None): | ||
""" | ||
Convert a structure in PDB format to mmCIF format. | ||
|
@@ -90,6 +91,11 @@ def run(fhandle): | |
---------- | ||
fhandle : an iterable giving the PDB file line-by-line. | ||
outname : str | ||
The base name of the output files. If None is given, tries to | ||
extract a name from the `.name` attribute of `fhandler`. If | ||
`fhandler` has no attribute name, assigns `cell`. | ||
Yields | ||
------ | ||
str (line-by-line) | ||
|
@@ -106,10 +112,17 @@ def run(fhandle): | |
yield '#\n' | ||
|
||
# Headers | ||
fname, _ = os.path.splitext(os.path.basename(fhandle.name)) | ||
if fname == '<stdin>': | ||
fname = 'cell' | ||
yield 'data_{}\n'.format(fname) | ||
_defname = 'cell' | ||
if outname is None: | ||
try: | ||
fn = fhandle.name | ||
outname = fn[:-4] if fn != '<stdin>' else _defname | ||
except AttributeError: | ||
outname = _defname | ||
|
||
fname_root = os.path.basename(outname) | ||
|
||
yield 'data_{}\n'.format(fname_root) | ||
|
||
yield '#\n' | ||
yield 'loop_\n' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.