Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
pdbparser
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NOEL Philippe
pdbparser
Commits
f20b7766
Commit
f20b7766
authored
Nov 30, 2018
by
NOEL Philippe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise parsing pdb
parent
09450558
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
src/main.rs
src/main.rs
+1
-1
src/pdb/read_pdb.rs
src/pdb/read_pdb.rs
+12
-7
tests/test.rs
tests/test.rs
+3
-3
No files found.
src/main.rs
View file @
f20b7766
...
...
@@ -9,6 +9,6 @@ fn main() {
println!
(
"Reduce protein"
);
let
chain_a
=
my_prot
.select_atoms
(
"chain a"
)
.unwrap
();
println!
(
"Prot : {}
\n
n chain: {}
\n
n res: {}
\n
n atom: {}"
,
chain_a
.name
,
chain_a
.get_number_chain
(),
chain
A
.get_number_residue
(),
chainA
.get_number_atom
());
println!
(
"Prot : {}
\n
n chain: {}
\n
n res: {}
\n
n atom: {}"
,
chain_a
.name
,
chain_a
.get_number_chain
(),
chain
_a
.get_number_residue
(),
chain_a
.get_number_atom
());
}
src/pdb/read_pdb.rs
View file @
f20b7766
...
...
@@ -78,15 +78,20 @@ pub fn parse_pdb(pdb: &str, name: &str) -> Protein {
for
line
in
reader
.lines
()
{
let
l
=
line
.unwrap
();
if
l
.starts_with
(
"HETAM"
)
||
l
.starts_with
(
"ATOM"
)
{
let
atom_name
=
&
l
[
12
..
17
]
.trim
()
.to_string
();
// First get the resname.
// If the "residue" is a protein residue, continue to parse the line and add informations to the protein
// else continue to the next one line
let
residue_name
=
&
l
[
17
..
20
]
.trim
();
if
is_protein_res
(
residue_name
,
&
lst_res
)
{
let
atom_name
=
&
l
[
12
..
17
]
.trim
()
.to_string
();
let
chain
=
l
[
21
..
22
]
.chars
()
.next
()
.unwrap
();
let
atom_number
=
parse_int
(
&
l
[
6
..
11
]
.to_string
());
let
residue_number
=
parse_int
(
&
l
[
22
..
26
]
.to_string
());
let
x
=
parse_float
(
&
l
[
30
..
38
]
.to_string
());
let
y
=
parse_float
(
&
l
[
38
..
46
]
.to_string
());
let
z
=
parse_float
(
&
l
[
46
..
54
]
.to_string
());
if
is_protein_res
(
residue_name
,
&
lst_res
)
{
// Add informations to the protein
protein
.update_protein
(
chain
,
residue_name
.to_string
(),
residue_number
as
u64
,
atom_name
.clone
(),
atom_number
as
u64
,
[
x
,
y
,
z
]);
}
}
...
...
tests/test.rs
View file @
f20b7766
...
...
@@ -38,12 +38,12 @@ fn f2_res() {
let
mut
my_prot
=
pdbparser
::
parse_pdb
(
"tests/tests_file/f2.pdb"
,
"f2"
);
let
chain_a
=
my_prot
.get_chain_ref
(
'A'
)
.unwrap
();
let
res
=
chain_
A
.get_residue_ref
(
1
)
.unwrap
();
let
res
=
chain_
a
.get_residue_ref
(
1
)
.unwrap
();
assert_eq!
(
"THR"
,
res
.name
());
let
res
=
chain_
A
.get_residue_ref
(
2
)
.unwrap
();
let
res
=
chain_
a
.get_residue_ref
(
2
)
.unwrap
();
assert_eq!
(
"SER"
,
res
.name
());
let
res
=
chain_
A
.get_residue_ref
(
chain_A
.get_number_residue
())
.unwrap
();
let
res
=
chain_
a
.get_residue_ref
(
chain_a
.get_number_residue
())
.unwrap
();
assert_eq!
(
"HSD"
,
res
.name
());
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment