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
43b5b277
Commit
43b5b277
authored
Nov 28, 2018
by
NOEL Philippe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support of hexa in atom number
parent
823247e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
src/main.rs
src/main.rs
+1
-1
src/pdb/read_pdb.rs
src/pdb/read_pdb.rs
+32
-3
No files found.
src/main.rs
View file @
43b5b277
...
@@ -8,7 +8,7 @@ fn main() {
...
@@ -8,7 +8,7 @@ fn main() {
println!
(
"Nb chain : {}"
,
toto
.get_number_chain
());
println!
(
"Nb chain : {}"
,
toto
.get_number_chain
());
println!
(
"Nb atom : {}"
,
toto
.get_atom_index
()
.len
());
println!
(
"Nb atom : {}"
,
toto
.get_atom_index
()
.len
());
let
toto_A
=
toto
.select_atoms
(
"chain A"
)
.unwrap
();
let
toto_A
=
toto
.select_atoms
(
"chain A"
)
.unwrap
();
let
toto_A
=
toto_A
.select_atoms
(
"backbone"
)
.unwrap
();
//
let toto_A = toto_A.select_atoms("backbone").unwrap();
println!
(
"Nb res : {}"
,
toto_A
.get_number_residue
());
println!
(
"Nb res : {}"
,
toto_A
.get_number_residue
());
println!
(
"Nb chain : {}"
,
toto_A
.get_number_chain
());
println!
(
"Nb chain : {}"
,
toto_A
.get_number_chain
());
println!
(
"Nb atom : {}"
,
toto_A
.get_atom_index
()
.len
());
println!
(
"Nb atom : {}"
,
toto_A
.get_atom_index
()
.len
());
...
...
src/pdb/read_pdb.rs
View file @
43b5b277
...
@@ -24,6 +24,8 @@ fn parse_float(s: &String) -> f32 {
...
@@ -24,6 +24,8 @@ fn parse_float(s: &String) -> f32 {
/// Parse the string to return a i64. The `trim` is used to remove
/// Parse the string to return a i64. The `trim` is used to remove
/// /n and spaces.
/// /n and spaces.
/// In large PDB, atom number can be > 99,999.
/// In VMD, the atom number is in hexadecimal after 99,999
///
///
/// # Errors
/// # Errors
/// Will return 0 if the String cannot be convert and print the error
/// Will return 0 if the String cannot be convert and print the error
...
@@ -32,8 +34,13 @@ fn parse_int(s: &String) -> i64 {
...
@@ -32,8 +34,13 @@ fn parse_int(s: &String) -> i64 {
match
s
.trim
()
.parse
::
<
i64
>
()
{
match
s
.trim
()
.parse
::
<
i64
>
()
{
Ok
(
n
)
=>
n
,
Ok
(
n
)
=>
n
,
Err
(
e
)
=>
{
Err
(
e
)
=>
{
println!
(
"{}"
,
e
);
match
i64
::
from_str_radix
(
s
.trim
(),
16
)
{
0
Ok
(
n
)
=>
return
n
,
Err
(
_
)
=>
{
println!
(
"{}"
,
e
);
return
0
}
}
}
}
}
}
}
}
...
@@ -48,6 +55,14 @@ fn parse_int(s: &String) -> i64 {
...
@@ -48,6 +55,14 @@ fn parse_int(s: &String) -> i64 {
/// ```
/// ```
pub
fn
parse_pdb
(
f
:
&
str
)
->
Protein
{
pub
fn
parse_pdb
(
f
:
&
str
)
->
Protein
{
// Allocate here to avoid multiple allocation for every call
let
lst_res
=
vec!
[
"ARG"
,
"HIS"
,
"HSE"
,
"HSD"
,
"LYS"
,
"LYS"
,
"ASP"
,
"GLU"
,
"SER"
,
"THR"
,
"ASN"
,
"GLN"
,
"CYS"
,
"SEC"
,
"GLY"
,
"PRO"
,
"ALA"
,
"VAL"
,
"ILE"
,
"LEU"
,
"MET"
,
"PHE"
,
"TYR"
,
"TRP"
];
// Check if the file exist and/or can be read
// Check if the file exist and/or can be read
let
f
=
match
File
::
open
(
f
)
{
let
f
=
match
File
::
open
(
f
)
{
Ok
(
f
)
=>
f
,
Ok
(
f
)
=>
f
,
...
@@ -71,8 +86,22 @@ pub fn parse_pdb(f: &str) -> Protein {
...
@@ -71,8 +86,22 @@ pub fn parse_pdb(f: &str) -> Protein {
let
x
=
parse_float
(
&
l
[
30
..
38
]
.to_string
());
let
x
=
parse_float
(
&
l
[
30
..
38
]
.to_string
());
let
y
=
parse_float
(
&
l
[
38
..
46
]
.to_string
());
let
y
=
parse_float
(
&
l
[
38
..
46
]
.to_string
());
let
z
=
parse_float
(
&
l
[
46
..
54
]
.to_string
());
let
z
=
parse_float
(
&
l
[
46
..
54
]
.to_string
());
protein
.update_protein
(
chain
,
residue_name
.clone
(),
residue_number
as
u64
,
atom_name
.clone
(),
atom_number
as
u64
,
[
x
,
y
,
z
]);
if
is_protein_res
(
residue_name
,
&
lst_res
)
{
protein
.update_protein
(
chain
,
residue_name
.clone
(),
residue_number
as
u64
,
atom_name
.clone
(),
atom_number
as
u64
,
[
x
,
y
,
z
]);
}
}
}
}
}
protein
protein
}
fn
is_protein_res
(
r
:
&
str
,
lst
:
&
Vec
<&
str
>
)
->
bool
{
let
r
=
r
.to_uppercase
();
for
res
in
lst
{
if
r
==
*
res
{
return
true
}
}
false
}
}
\ 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