Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MIT_MAHE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2022 Competition
Software Tools
MIT_MAHE
Commits
61f35be0
Commit
61f35be0
authored
2 years ago
by
Ashrith Sagar Yedlapalli
Browse files
Options
Downloads
Patches
Plain Diff
Update pdb_chains.py
parent
4aec805e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pdb_chains.py
+38
-0
38 additions, 0 deletions
pdb_chains.py
with
38 additions
and
0 deletions
pdb_chains.py
0 → 100644
+
38
−
0
View file @
61f35be0
"""
Include pdb chains.
"""
import
sys
import
argparse
def
_main
():
# For the command line parser.
parser
=
argparse
.
ArgumentParser
(
description
=
'
Modify pdb chains
'
)
parser
.
add_argument
(
'
input_file
'
,
type
=
str
,
help
=
'
Input .pdb file
'
)
parser
.
add_argument
(
'
chains
'
,
type
=
list
,
help
=
'
List of chains to be included
'
)
parser
.
add_argument
(
'
-o
'
,
'
--output
'
,
dest
=
'
output_file
'
,
type
=
str
,
help
=
'
Output filename
'
)
args
=
parser
.
parse_args
()
with
open
(
args
.
input_file
,
"
r
"
)
as
file
:
contents
=
file
.
readlines
()
# If --output not specified, use input_file filename.
output_file
=
args
.
output_file
if
args
.
output_file
else
args
.
input_file
.
replace
(
"
.pdb
"
,
"
_chains.pdb
"
)
new_contents
=
[]
chains
=
args
.
chains
chains
.
append
(
"
_
"
)
# So that last pop doesn't make the list empty.
chain
=
chains
.
pop
(
0
)
for
line
in
contents
:
if
line
.
startswith
(
"
TER
"
)
|
line
.
startswith
(
"
END
"
):
chain
=
chains
.
pop
(
0
)
new_line
=
line
if
not
line
.
startswith
(
"
ATOM
"
)
else
line
[:
21
]
+
chain
+
line
[
22
:]
try
:
new_contents
.
append
(
new_line
)
except
:
pass
# Save output.
new_contents
=
""
.
join
(
new_contents
)
file
=
open
(
output_file
,
"
w
"
)
file
.
write
(
new_contents
)
if
__name__
==
"
__main__
"
:
_main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment