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
6
Issues
6
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
8f1754a8
Commit
8f1754a8
authored
Dec 06, 2018
by
NOEL Philippe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PDB writer
parent
32e67797
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1142 additions
and
7 deletions
+1142
-7
src/lib.rs
src/lib.rs
+2
-0
src/main.rs
src/main.rs
+11
-5
src/pdb/atom.rs
src/pdb/atom.rs
+1
-1
src/pdb/mod.rs
src/pdb/mod.rs
+1
-0
src/pdb/residue.rs
src/pdb/residue.rs
+1
-1
src/pdb/write_pdb.rs
src/pdb/write_pdb.rs
+39
-0
test.f2.txt
test.f2.txt
+1087
-0
No files found.
src/lib.rs
View file @
8f1754a8
...
...
@@ -7,6 +7,8 @@
mod
pdb
;
pub
use
self
::
pdb
::
read_pdb
::
parse_pdb
as
parse_pdb
;
pub
use
self
::
pdb
::
write_pdb
::
write_pdb
;
pub
use
self
::
pdb
::
protein
::
Protein
;
pub
use
self
::
pdb
::
atom
::
Atom
;
...
...
src/main.rs
View file @
8f1754a8
...
...
@@ -3,12 +3,18 @@ extern crate pdbparser;
use
pdbparser
::
*
;
fn
main
()
{
let
my_prot
=
parse_pdb
(
"tests/tests_file/5jpq.pdb"
,
"5jpq"
);
let
my_prot
=
parse_pdb
(
"tests/tests_file/f2.pdb"
,
"5jpq"
);
match
write_pdb
(
&
my_prot
,
"toto.pdb"
){
Ok
(
_
)
=>
(),
Err
(
e
)
=>
println!
(
"Error : {}"
,
e
),
};
// println!("Prot : {} \nn chain: {}\nn res: {}\nn atom: {}", my_prot.name, my_prot.get_number_chain(), my_prot.get_number_residue(), my_prot.get_number_atom());
// println!("Reduce protein");
// let chain_a = my_prot.select_atoms("chain a").unwrap();
// println!("Prot : {} \nn chain: {}\nn res: {}\nn atom: {}", chain_a.name, chain_a.get_number_chain(), chain_a.get_number_residue(), chain_a.get_number_atom());
println!
(
"Prot : {}
\n
n chain: {}
\n
n res: {}
\n
n atom: {}"
,
my_prot
.name
,
my_prot
.get_number_chain
(),
my_prot
.get_number_residue
(),
my_prot
.get_number_atom
());
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
(),
chain_a
.get_number_atom
());
}
src/pdb/atom.rs
View file @
8f1754a8
...
...
@@ -40,7 +40,7 @@ impl Atom {
/// Get the name of the atom
///
pub
fn
name
(
self
)
->
String
{
pub
fn
name
(
&
self
)
->
String
{
self
.name
.clone
()
}
...
...
src/pdb/mod.rs
View file @
8f1754a8
...
...
@@ -3,5 +3,6 @@ pub mod protein;
pub
mod
residue
;
pub
mod
read_pdb
;
pub
mod
chain
;
pub
mod
write_pdb
;
mod
selection_atom
;
\ No newline at end of file
src/pdb/residue.rs
View file @
8f1754a8
...
...
@@ -40,7 +40,7 @@ impl Residue {
self
.name
.clone
()
}
/// Get the
number
of the residue
/// Get the
residue ID
of the residue
///
pub
fn
get_res_num
(
&
self
)
->
u64
{
self
.res_num
...
...
src/pdb/write_pdb.rs
0 → 100644
View file @
8f1754a8
use
super
::
protein
::
Protein
;
use
std
::
fs
::
File
;
use
std
::
io
::
Write
;
use
std
::
io
;
/// Write a PDB file for the `Protein`.
/// Be careful, the protein is write with the atom numbers in its structure. Remind to use the method
/// my_protein.refine_numerotation() before !
pub
fn
write_pdb
(
my_prot
:
&
Protein
,
file
:
&
str
)
->
io
::
Result
<
()
>
{
let
mut
output_pdb
=
File
::
create
(
file
)
?
;
for
chain
in
&
my_prot
.lst_chain
{
let
chain_name
=
chain
.get_name
();
for
residue
in
&
chain
.lst_res
{
let
res_name
=
residue
.name
();
let
res_id
=
residue
.get_res_num
();
for
atom
in
&
residue
.lst_atom
{
let
atom_name
=
atom
.name
();
let
atom_id
=
atom
.number
;
let
atom_coord
=
atom
.coord
;
output_pdb
.write_fmt
(
format_args!
(
"ATOM {:>5} {:<4}{:>3} {}{:>4} {:>8.3}{:>8.3}{:>8.3}{:>6.2}{:>6.2}
\n
"
,
atom_id
,
atom_name
,
res_name
,
chain_name
,
res_id
,
atom_coord
[
0
],
atom_coord
[
1
],
atom_coord
[
2
],
1.0
,
0.0
))
?
;
}
}
}
Ok
(())
}
\ No newline at end of file
test.f2.txt
0 → 100644
View file @
8f1754a8
This diff is collapsed.
Click to expand it.
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