Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
simple_filters
FileExistFilter.cc
Go to the documentation of this file.
1
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2
// vi: set ts=2 noet:
3
//
4
// (c) Copyright Rosetta Commons Member Institutions.
5
// (c) This file is part of the Rosetta software suite and is made available under license.
6
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8
// (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9
10
/// @file protocols/simple_filters/FileExistFilter.cc
11
/// @brief
12
/// @author Sarel Fleishman
13
14
15
//Unit Headers
16
#include <
protocols/simple_filters/FileExistFilter.hh
>
17
#include <
protocols/simple_filters/FileExistFilterCreator.hh
>
18
#include <utility/tag/Tag.hh>
19
//Project Headers
20
#include <basic/Tracer.hh>
21
#include <fstream>
22
#include <iostream>
23
namespace
protocols{
24
namespace
simple_filters {
25
26
using namespace
core;
27
using namespace
core::scoring;
28
29
static
basic::Tracer
TR
(
"protocols.simple_filters.FileExistFilter"
);
30
31
protocols::filters::FilterOP
32
FileExistFilterCreator::create_filter
()
const
{
return
new
FileExistFilter
; }
33
34
std::string
35
FileExistFilterCreator::keyname
()
const
{
return
"FileExist"
; }
36
37
//default ctor
38
FileExistFilter::FileExistFilter
() :
39
protocols::filters::
Filter
(
"FileExist"
),
40
filename_(
""
),
41
ignore_zero_byte_( false )
42
{}
43
44
FileExistFilter::~FileExistFilter
() {}
45
46
void
47
FileExistFilter::parse_my_tag
(
utility::tag::TagPtr
const
tag,
moves::DataMap
&,
filters::Filters_map
const
&,
moves::Movers_map
const
&,
core::pose::Pose
const
& )
48
{
49
filename_
= tag->getOption<
std::string
>(
"filename"
);
50
ignore_zero_byte
( tag->getOption<
bool
>(
"ignore_zero_byte"
,
false
) );
51
}
52
53
bool
54
FileExistFilter::apply
(
core::pose::Pose
const
& pose )
const
{
55
return
compute
( pose );
56
}
57
58
void
59
FileExistFilter::report
( std::ostream & out,
core::pose::Pose
const
& pose )
const
{
60
out<<
"File "
<<
filename_
<<
" exists? "
<<
compute
( pose )<<
'\n'
;
61
}
62
63
core::Real
64
FileExistFilter::report_sm
(
core::pose::Pose
const
& pose )
const
{
65
return
(
compute
( pose ) );
66
}
67
68
core::Real
69
FileExistFilter::compute
(
70
core::pose::Pose
const
&
/*pose*/
71
)
const
{
72
using namespace
std;
73
74
ifstream infile;
75
infile.open(
filename_
.c_str(), ios::in );
76
if
( !infile.good() )
77
return
false
;
78
79
if
( !
ignore_zero_byte
() )
80
return
true
;
81
82
/// if the file is there and we're ignoring zero-byte files, we return true only if the file contains information
83
core::Size
const
begin = infile.tellg();
84
infile.seekg( 0,
ios::end
);
85
core::Size
const
end
= infile.tellg();
86
return
(
end
- begin > 0 );
87
}
88
89
void
FileExistFilter::filename
(
std::string
const
f )
90
{
91
filename_
= f;
92
}
93
94
std::string
FileExistFilter::filename
()
const
95
{
96
return
filename_
;
97
}
98
99
}
100
}
Generated on Sat Jun 1 2013 12:13:27 for Rosetta 3.5 by
1.8.4