This file is indexed.

/usr/include/pbbam/internal/PbiFilter.inl is in libpbbam-dev 0.7.4+ds-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// Copyright (c) 2014-2015, Pacific Biosciences of California, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted (subject to the limitations in the
// disclaimer below) provided that the following conditions are met:
//
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//
//  * Redistributions in binary form must reproduce the above
//    copyright notice, this list of conditions and the following
//    disclaimer in the documentation and/or other materials provided
//    with the distribution.
//
//  * Neither the name of Pacific Biosciences nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
// GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY PACIFIC
// BIOSCIENCES AND ITS CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL PACIFIC BIOSCIENCES OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// File Description
/// \file PbiFilter.inl
/// \brief Inline implementations for the PbiFilter class.
//
// Author: Derek Barnett

#include "pbbam/PbiFilter.h"
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

namespace PacBio {
namespace BAM {
namespace internal {

/// \internal
///
/// This class wraps a the basic PBI filter (whether property filter or some operator
/// e.g. union, intersect, etc.). The wrapper allows PbiFilters to hold heterogeneous,
/// recursive filter types - without exposing pointers & worrying about memory ownership
/// issues between client & library.
///
/// Filters can be given by value from client code and we will wrap them for composition.
///
/// \code{.cpp}
///    PbiFilter f1(PbiZmwFilter(42));
///    PbiFilter f2;
///    f2.Add(PbiQueryLengthFilter(3000, GREATER_THAN_EQUAL));
///    f2.Add(MyApplicationCustomFilter("foo"));
///    PbiFilter intersect = PbiFilter::Intersect(f1, f2);
///    ...
/// \endcode
///
struct FilterWrapper
{
public:
    template<typename T> FilterWrapper(T x);

    FilterWrapper(const FilterWrapper& other);
    FilterWrapper(FilterWrapper&&) noexcept = default;
    FilterWrapper& operator=(const FilterWrapper& other);
    FilterWrapper& operator=(FilterWrapper&&) noexcept = default;
    ~FilterWrapper(void);

public:
    bool Accepts(const PacBio::BAM::PbiRawData& idx, const size_t row) const;

private:
    struct WrapperInterface
    {
        virtual ~WrapperInterface(void) = default;
        virtual WrapperInterface* Clone(void) const =0;
        virtual bool Accepts(const PacBio::BAM::PbiRawData& idx,
                             const size_t row) const =0;
    };

    template<typename T>
    struct WrapperImpl : public WrapperInterface
    {
        WrapperImpl(T x);
        WrapperImpl(const WrapperImpl& other);
        WrapperInterface* Clone(void) const;
        bool Accepts(const PacBio::BAM::PbiRawData& idx, const size_t row) const;
        T data_;
    };

private:
    std::unique_ptr<WrapperInterface> self_;
};

// ---------------
// FilterWrapper
// ---------------

template<typename T>
inline FilterWrapper::FilterWrapper(T x)
    : self_(new WrapperImpl<T>(std::move(x)))
{ }

inline FilterWrapper::FilterWrapper(const FilterWrapper& other)
    : self_(other.self_->Clone())
{ }

inline FilterWrapper& FilterWrapper::operator=(const FilterWrapper& other)
{
    self_.reset(other.self_->Clone());
    return *this;
}

inline FilterWrapper::~FilterWrapper(void) { }

inline bool FilterWrapper::Accepts(const PbiRawData& idx, const size_t row) const
{ return self_->Accepts(idx, row); }

// ----------------
// WrapperImpl<T>
// ----------------

template<typename T>
inline FilterWrapper::WrapperImpl<T>::WrapperImpl(T x)
    : FilterWrapper::WrapperInterface()
    , data_(std::move(x))
{
    BOOST_CONCEPT_ASSERT((PbiFilterConcept<T>));
}

template<typename T>
inline FilterWrapper::WrapperImpl<T>::WrapperImpl(const WrapperImpl& other)
    : FilterWrapper::WrapperInterface()
    , data_(other.data_)
{ }

template<typename T>
inline FilterWrapper::WrapperInterface* FilterWrapper::WrapperImpl<T>::Clone(void) const
{ return new WrapperImpl(*this); }

template<typename T>
inline bool FilterWrapper::WrapperImpl<T>::Accepts(const PbiRawData& idx,
                                                   const size_t row) const
{ return data_.Accepts(idx, row); }

struct PbiFilterPrivate
{
    PbiFilterPrivate(PbiFilter::CompositionType type)
        : type_(type)
    { }

    template<typename T>
    void Add(T&& filter)
    {
        filters_.emplace_back(std::move(filter));
    }

    std::unique_ptr<internal::PbiFilterPrivate> DeepCopy(void)
    {
        auto copy = std::unique_ptr<PbiFilterPrivate>{ new PbiFilterPrivate{type_} };
        copy->filters_ = this->filters_;
        return copy;
    }

    bool Accepts(const PbiRawData& idx, const size_t row) const
    {
        // no filter -> accepts every record
        if (filters_.empty())
            return true;

        // intersection of child filters
        if (type_ == PbiFilter::INTERSECT) {
            for (const auto& filter : filters_) {
                if (!filter.Accepts(idx, row))
                    return false; // break early on failure
            }
            return true; // all passed
        }

        // union of child filters
        else if (type_ == PbiFilter::UNION) {
            for (const auto& filter : filters_) {
                if (filter.Accepts(idx, row))
                    return true; // break early on pass
            }
            return false; // none passed
        }

        else
            //assert(false); // invalid composite filter type
            throw std::runtime_error("invalid composite filter type in PbiFilterPrivate::Accepts");
    }

    PbiFilter::CompositionType type_;
    std::vector<FilterWrapper> filters_;
};

} // namespace internal

inline PbiFilter::PbiFilter(const CompositionType type)
    : d_{ new internal::PbiFilterPrivate{ type } }
{ }

template<typename T> inline
PbiFilter::PbiFilter(const T& filter)
    : d_{ new internal::PbiFilterPrivate{ PbiFilter::INTERSECT } }
{
    Add(filter);
}

template<typename T> inline
PbiFilter::PbiFilter(T&& filter)
    : d_{ new internal::PbiFilterPrivate{ PbiFilter::INTERSECT } }
{
    Add(std::move(filter));
}

inline PbiFilter::PbiFilter(const std::vector<PbiFilter>& filters)
    : d_{ new internal::PbiFilterPrivate{ PbiFilter::INTERSECT } }
{
    Add(filters);
}

inline PbiFilter::PbiFilter(std::vector<PbiFilter>&& filters)
    : d_{ new internal::PbiFilterPrivate{ PbiFilter::INTERSECT} }
{
    Add(std::move(filters));
}

inline PbiFilter::PbiFilter(const PbiFilter& other)
    : d_{ other.d_->DeepCopy() }
{ }

inline PbiFilter::PbiFilter(PbiFilter&& other) noexcept
    : d_{ std::move(other.d_) }
{ }

inline PbiFilter& PbiFilter::operator=(const PbiFilter& other)
{
    d_ = other.d_->DeepCopy();
    return *this;
}

inline PbiFilter& PbiFilter::operator=(PbiFilter&& other) noexcept
{
    d_ = std::move(other.d_);
    return *this;
}

inline PbiFilter::~PbiFilter(void) { }

inline bool PbiFilter::Accepts(const PacBio::BAM::PbiRawData& idx,
                               const size_t row) const
{ return d_->Accepts(idx, row); }

template<typename T>
inline PbiFilter& PbiFilter::Add(const T& filter)
{
    T copy = filter;
    return Add(std::move(copy));
}

template<typename T>
inline PbiFilter& PbiFilter::Add(T&& filter)
{
    d_->Add(std::move(filter));
    return *this;
}

inline PbiFilter& PbiFilter::Add(const PbiFilter& filter)
{
    PbiFilter copy = filter;
    return Add(std::move(copy));
}

inline PbiFilter& PbiFilter::Add(PbiFilter&& filter)
{
    d_->Add(std::move(filter));
    return *this;
}

inline PbiFilter& PbiFilter::Add(const std::vector<PbiFilter>& filters)
{
    std::vector<PbiFilter> copy = filters;
    return Add(std::move(copy));
}

inline PbiFilter& PbiFilter::Add(std::vector<PbiFilter>&& filters)
{
    for (auto&& filter : filters)
        d_->Add(std::move(filter));
    return *this;
}

inline bool PbiFilter::IsEmpty(void) const
{ return d_->filters_.empty(); }

} // namespace BAM
} // namespace PacBio