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
289c78fd
Commit
289c78fd
authored
Nov 26, 2018
by
NOEL Philippe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.inria.fr:pnoel/pdbparser
parents
52586cce
f5832f27
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
18 deletions
+51
-18
src/lib.rs
src/lib.rs
+5
-0
src/main.rs
src/main.rs
+1
-1
src/pdb/atom.rs
src/pdb/atom.rs
+2
-2
src/pdb/protein.rs
src/pdb/protein.rs
+22
-1
src/pdb/read_pdb.rs
src/pdb/read_pdb.rs
+10
-5
src/tests/test.rs
src/tests/test.rs
+0
-9
tests/test.rs
tests/test.rs
+11
-0
No files found.
src/lib.rs
View file @
289c78fd
//! # pdbparser
//!
//! `pdbparser` is a library to manipulate protein structure. It can parse, create and filter PDB files.
//!
mod
pdb
;
mod
pdb
;
pub
use
self
::
pdb
::
read_pdb
::
parse_pdb
as
parse_pdb
;
pub
use
self
::
pdb
::
read_pdb
::
parse_pdb
as
parse_pdb
;
...
...
src/main.rs
View file @
289c78fd
...
@@ -4,7 +4,7 @@ use pdbparser::*;
...
@@ -4,7 +4,7 @@ use pdbparser::*;
fn
main
()
{
fn
main
()
{
//let tutu = open_pdb_file("src/tests/f2_adn.pdb");
//let tutu = open_pdb_file("src/tests/f2_adn.pdb");
let
tutu
=
parse_pdb
(
"src/tests_file/
5jpq
.pdb"
);
let
tutu
=
parse_pdb
(
"src/tests_file/
f2
.pdb"
);
println!
(
"Nb res : {}"
,
tutu
.get_number_residue
());
println!
(
"Nb res : {}"
,
tutu
.get_number_residue
());
println!
(
"Nb chain : {}"
,
tutu
.get_number_chain
());
println!
(
"Nb chain : {}"
,
tutu
.get_number_chain
());
}
}
src/pdb/atom.rs
View file @
289c78fd
...
@@ -35,10 +35,10 @@ impl Atom {
...
@@ -35,10 +35,10 @@ impl Atom {
/// let h1 = pdbparser::Atom::new(String::from("HT1"), 1, [1.0, 5.0, 2.0]);
/// let h1 = pdbparser::Atom::new(String::from("HT1"), 1, [1.0, 5.0, 2.0]);
/// let h2 = pdbparser::Atom::new(String::from("HT1"), 1, [11.0, 17.0, 5.0]);
/// let h2 = pdbparser::Atom::new(String::from("HT1"), 1, [11.0, 17.0, 5.0]);
///
///
/// assert_eq!(15.905973, h1.compute_distance(h2));
/// assert_eq!(15.905973, h1.compute_distance(
&
h2));
///
///
/// ````
/// ````
pub
fn
compute_distance
(
&
self
,
a
:
Atom
)
->
f32
{
pub
fn
compute_distance
(
&
self
,
a
:
&
Atom
)
->
f32
{
(
(
(
self
.coord
[
0
]
-
a
.coord
[
0
])
.powi
(
2
)
+
(
self
.coord
[
0
]
-
a
.coord
[
0
])
.powi
(
2
)
+
(
self
.coord
[
1
]
-
a
.coord
[
1
])
.powi
(
2
)
+
(
self
.coord
[
1
]
-
a
.coord
[
1
])
.powi
(
2
)
+
...
...
src/pdb/protein.rs
View file @
289c78fd
...
@@ -50,7 +50,7 @@ impl<'a> Protein {
...
@@ -50,7 +50,7 @@ impl<'a> Protein {
return
true
return
true
}
}
}
}
return
false
false
}
}
/// Return a mutable reference of a chaine with its name. Return None if the
/// Return a mutable reference of a chaine with its name. Return None if the
...
@@ -147,6 +147,27 @@ impl<'a> Protein {
...
@@ -147,6 +147,27 @@ impl<'a> Protein {
n
n
}
}
/// Return the number of atom in the protein
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_prot = pdbparser::parse_pdb("src/tests_file/f2.pdb");
/// assert_eq!(1085, my_prot.get_number_atom());
/// ````
pub
fn
get_number_atom
(
&
self
)
->
u64
{
let
mut
n
:
u64
=
0
;
for
chain
in
self
.lst_chain
.iter
()
{
for
res
in
chain
.lst_res
.iter
()
{
for
_
in
res
.lst_atom
.iter
()
{
n
+=
1
;
}
}
}
n
}
/// Function that add information on the protein (used in the parsing)
/// Function that add information on the protein (used in the parsing)
/// /!\Change this to a macro!
/// /!\Change this to a macro!
...
...
src/pdb/read_pdb.rs
View file @
289c78fd
...
@@ -4,9 +4,7 @@ use std::io::BufReader;
...
@@ -4,9 +4,7 @@ use std::io::BufReader;
use
std
::
process
;
use
std
::
process
;
use
super
::
protein
::
Protein
;
use
super
::
protein
::
Protein
;
use
super
::
chain
::
Chain
;
use
super
::
residue
::
Residue
;
use
super
::
atom
::
Atom
;
/// Parse the string to return a f32. The `trim` is used to remove
/// Parse the string to return a f32. The `trim` is used to remove
/// /n and spaces.
/// /n and spaces.
...
@@ -40,7 +38,14 @@ fn parse_int(s: &String) -> i64 {
...
@@ -40,7 +38,14 @@ fn parse_int(s: &String) -> i64 {
}
}
}
}
/// Parse the pdb file and return a protein structure
///
/// # Examples
/// ```
/// use pdbparser;
/// let my_prot = pdbparser::parse_pdb("src/tests_file/f2.pdb");
/// assert_eq!(66, my_prot.get_number_residue());
/// ```
pub
fn
parse_pdb
(
f
:
&
str
)
->
Protein
{
pub
fn
parse_pdb
(
f
:
&
str
)
->
Protein
{
// Check if the file exist and/or can be read
// Check if the file exist and/or can be read
...
@@ -66,7 +71,7 @@ pub fn parse_pdb(f: &str) -> Protein {
...
@@ -66,7 +71,7 @@ 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
.clone
()
,
residue_name
.clone
(),
residue_number
as
u64
,
atom_name
.clone
(),
atom_number
as
u64
,
[
x
,
y
,
z
]);
protein
.update_protein
(
chain
,
residue_name
.clone
(),
residue_number
as
u64
,
atom_name
.clone
(),
atom_number
as
u64
,
[
x
,
y
,
z
]);
}
}
}
}
protein
protein
...
...
src/tests/test.rs
deleted
100644 → 0
View file @
52586cce
extern
crate
pdbparser
;
use
pdbparser
::
Atom
;
#[test]
fn
test_atom
()
{
Atom
::
new
();
assert_eq!
(
"rr"
,
"rr"
);
}
\ No newline at end of file
tests/test.rs
0 → 100644
View file @
289c78fd
extern
crate
pdbparser
;
#[test]
fn
test_parse_f2
()
{
use
pdbparser
;
let
my_prot
=
pdbparser
::
parse_pdb
(
"src/tests_file/f2.pdb"
);
assert_eq!
(
1
,
my_prot
.get_number_chain
());
assert_eq!
(
66
,
my_prot
.get_number_residue
());
assert_eq!
(
1085
,
my_prot
.get_number_atom
());
}
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