Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
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
schwede
openstructure
Commits
8375f3bf
Commit
8375f3bf
authored
13 years ago
by
Marco Biasini
Committed by
Bienchen
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added gzip support to PDBWriter
parent
380279e8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/io/src/mol/pdb_writer.cc
+24
-10
24 additions, 10 deletions
modules/io/src/mol/pdb_writer.cc
modules/io/src/mol/pdb_writer.hh
+3
-0
3 additions, 0 deletions
modules/io/src/mol/pdb_writer.hh
with
27 additions
and
10 deletions
modules/io/src/mol/pdb_writer.cc
+
24
−
10
View file @
8375f3bf
...
@@ -20,9 +20,14 @@
...
@@ -20,9 +20,14 @@
Author: Marco Biasini
Author: Marco Biasini
*/
*/
#include
<locale>
#include
<locale>
#include
<boost/format.hpp>
#include
<string.h>
#include
<string.h>
#include
<boost/format.hpp>
#include
<boost/iostreams/filter/gzip.hpp>
#include
<boost/filesystem/convenience.hpp>
#include
<boost/algorithm/string.hpp>
#include
<ost/io/io_exception.hh>
#include
<ost/io/io_exception.hh>
#include
<ost/mol/atom_handle.hh>
#include
<ost/mol/atom_handle.hh>
#include
<ost/mol/residue_handle.hh>
#include
<ost/mol/residue_handle.hh>
...
@@ -332,7 +337,7 @@ PDBWriter::PDBWriter(std::ostream& stream, const IOProfile& profile):
...
@@ -332,7 +337,7 @@ PDBWriter::PDBWriter(std::ostream& stream, const IOProfile& profile):
multi_model_
(
false
),
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
is_pqr_
(
false
),
multi_model_
(
false
),
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
is_pqr_
(
false
),
profile_
(
profile
)
profile_
(
profile
)
{
{
out_
.
push
(
outstream_
);
}
}
PDBWriter
::
PDBWriter
(
const
boost
::
filesystem
::
path
&
filename
,
PDBWriter
::
PDBWriter
(
const
boost
::
filesystem
::
path
&
filename
,
...
@@ -346,19 +351,28 @@ PDBWriter::PDBWriter(const boost::filesystem::path& filename,
...
@@ -346,19 +351,28 @@ PDBWriter::PDBWriter(const boost::filesystem::path& filename,
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
is_pqr_
(
false
),
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
is_pqr_
(
false
),
profile_
(
profile
),
filename_
(
""
)
profile_
(
profile
),
filename_
(
""
)
{
{
if
(
boost
::
iequals
(
".gz"
,
boost
::
filesystem
::
extension
(
filename
)))
{
out_
.
push
(
boost
::
iostreams
::
gzip_compressor
());
}
out_
.
push
(
outstream_
);
}
}
PDBWriter
::
PDBWriter
(
const
String
&
filename
,
const
IOProfile
&
profile
)
:
PDBWriter
::
PDBWriter
(
const
String
&
filename
,
const
IOProfile
&
profile
)
:
outfile_
(
filename
.
c_str
()),
outstream_
(
outfile_
),
mol_count_
(
0
),
line_
(
80
),
outfile_
(
filename
.
c_str
()),
outstream_
(
outfile_
),
mol_count_
(
0
),
line_
(
80
),
multi_model_
(
false
),
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
multi_model_
(
false
),
charmm_style_
(
profile
.
dialect
==
"CHARMM"
),
is_pqr_
(
false
),
profile_
(
profile
),
filename_
(
filename
)
is_pqr_
(
false
),
profile_
(
profile
),
filename_
(
filename
)
{}
{
if
(
boost
::
iequals
(
".gz"
,
boost
::
filesystem
::
extension
(
filename
)))
{
out_
.
push
(
boost
::
iostreams
::
gzip_compressor
());
}
out_
.
push
(
outstream_
);
}
void
PDBWriter
::
WriteModelLeader
()
void
PDBWriter
::
WriteModelLeader
()
{
{
++
mol_count_
;
++
mol_count_
;
if
(
multi_model_
)
{
if
(
multi_model_
)
{
out
stream
_
<<
"MODEL "
<<
mol_count_
<<
std
::
endl
;
out_
<<
"MODEL "
<<
mol_count_
<<
std
::
endl
;
}
else
if
(
mol_count_
>
1
)
{
}
else
if
(
mol_count_
>
1
)
{
throw
IOException
(
"Trying to write several models into one file with "
);
throw
IOException
(
"Trying to write several models into one file with "
);
}
}
...
@@ -367,14 +381,14 @@ void PDBWriter::WriteModelLeader()
...
@@ -367,14 +381,14 @@ void PDBWriter::WriteModelLeader()
void
PDBWriter
::
WriteModelTrailer
()
void
PDBWriter
::
WriteModelTrailer
()
{
{
if
(
multi_model_
)
{
if
(
multi_model_
)
{
out
stream
_
<<
"ENDMDL"
<<
std
::
endl
;
out_
<<
"ENDMDL"
<<
std
::
endl
;
}
}
}
}
template
<
typename
H
>
template
<
typename
H
>
void
PDBWriter
::
WriteModel
(
H
ent
)
void
PDBWriter
::
WriteModel
(
H
ent
)
{
{
if
(
!
out
stream
_
)
{
if
(
!
out_
)
{
if
(
!
filename_
.
empty
())
{
if
(
!
filename_
.
empty
())
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"Can't write PDB to file '"
<<
filename_
<<
"'"
;
ss
<<
"Can't write PDB to file '"
<<
filename_
<<
"'"
;
...
@@ -384,10 +398,10 @@ void PDBWriter::WriteModel(H ent)
...
@@ -384,10 +398,10 @@ void PDBWriter::WriteModel(H ent)
}
}
ForcePOSIX
posix
;
ForcePOSIX
posix
;
this
->
WriteModelLeader
();
this
->
WriteModelLeader
();
PDBWriterImpl
writer
(
out
stream
_
,
line_
,
atom_indices_
,
charmm_style_
);
PDBWriterImpl
writer
(
out_
,
line_
,
atom_indices_
,
charmm_style_
);
writer
.
SetIsPQR
(
is_pqr_
);
writer
.
SetIsPQR
(
is_pqr_
);
ent
.
Apply
(
writer
);
ent
.
Apply
(
writer
);
PDBConectWriterImpl
con_writer
(
out
stream
_
,
atom_indices_
);
PDBConectWriterImpl
con_writer
(
out_
,
atom_indices_
);
ent
.
Apply
(
con_writer
);
ent
.
Apply
(
con_writer
);
this
->
WriteModelTrailer
();
this
->
WriteModelTrailer
();
}
}
...
@@ -410,7 +424,7 @@ void PDBWriter::Write(const mol::AtomHandleList& atoms)
...
@@ -410,7 +424,7 @@ void PDBWriter::Write(const mol::AtomHandleList& atoms)
mol
::
ChainHandle
last_chain
;
mol
::
ChainHandle
last_chain
;
for
(
mol
::
AtomHandleList
::
const_iterator
i
=
atoms
.
begin
(),
for
(
mol
::
AtomHandleList
::
const_iterator
i
=
atoms
.
begin
(),
e
=
atoms
.
end
();
i
!=
e
;
++
i
,
++
counter
)
{
e
=
atoms
.
end
();
i
!=
e
;
++
i
,
++
counter
)
{
write_atom
(
out
stream
_
,
line_
,
*
i
,
counter
,
is_pqr_
,
charmm_style_
);
write_atom
(
out_
,
line_
,
*
i
,
counter
,
is_pqr_
,
charmm_style_
);
}
}
this
->
WriteModelTrailer
();
this
->
WriteModelTrailer
();
}
}
...
@@ -418,7 +432,7 @@ void PDBWriter::Write(const mol::AtomHandleList& atoms)
...
@@ -418,7 +432,7 @@ void PDBWriter::Write(const mol::AtomHandleList& atoms)
PDBWriter
::~
PDBWriter
()
PDBWriter
::~
PDBWriter
()
{
{
out
stream
_
<<
"END "
;
out_
<<
"END "
;
}
}
}}
}}
This diff is collapsed.
Click to expand it.
modules/io/src/mol/pdb_writer.hh
+
3
−
0
View file @
8375f3bf
...
@@ -43,7 +43,9 @@ class EntityHandle;
...
@@ -43,7 +43,9 @@ class EntityHandle;
namespace
io
{
namespace
io
{
class
DLLEXPORT_OST_IO
PDBWriter
{
class
DLLEXPORT_OST_IO
PDBWriter
{
typedef
boost
::
iostreams
::
filtering_stream
<
boost
::
iostreams
::
output
>
OutStream
;
public:
public:
PDBWriter
(
const
String
&
filename
,
PDBWriter
(
const
String
&
filename
,
const
IOProfile
&
profile
);
const
IOProfile
&
profile
);
...
@@ -76,6 +78,7 @@ private:
...
@@ -76,6 +78,7 @@ private:
bool
is_pqr_
;
bool
is_pqr_
;
IOProfile
profile_
;
IOProfile
profile_
;
String
filename_
;
String
filename_
;
OutStream
out_
;
};
};
}}
}}
...
...
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