Skip to content

Commit 4e1f81f

Browse files
author
singerj
committed
Merge pull request #3 from singerj/gff_io
Adaption of parsers to new stream module
2 parents f2b78a5 + 06e6b61 commit 4e1f81f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1610
-1550
lines changed

core/include/seqan/align/align_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace seqan {
4444
// Forwards
4545
// ============================================================================
4646

47-
struct TagRaw_;
48-
typedef Tag<TagRaw_> Raw;
47+
struct Raw_;
48+
typedef Tag<Raw_> Raw;
4949

5050
// ============================================================================
5151
// Tags, Classes, Enums

core/include/seqan/arg_parse.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
// ===========================================================================
4343

4444
#include <seqan/basic.h>
45-
#include <seqan/file.h>
45+
//#include <seqan/file.h>
46+
#include <seqan/stream.h>
4647
#include <seqan/sequence.h>
4748

4849
// ===========================================================================

core/include/seqan/arg_parse/arg_parse_exceptions.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,8 @@ namespace seqan {
4545
// Class ParseError
4646
// ----------------------------------------------------------------------------
4747

48-
/*
49-
.Internal.Class.ParseError
50-
..cat:Miscellaneous
51-
..summary:General ParseError.
52-
*/
53-
54-
class ParseError : public RuntimeError
55-
{
56-
public:
57-
ParseError(std::string const & option) :
58-
RuntimeError(option)
59-
{}
60-
};
48+
// Defined in core/include/seqan/stream/tokenization.h
49+
struct ParseError;
6150

6251
// ----------------------------------------------------------------------------
6352
// Class InvalidOption

core/include/seqan/basic/test_system.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,53 @@ class TypedTestFactory_<TTestCase, TagList<TType, TSubList> >
349349
template <typename SEQAN_TParam> \
350350
void SEQAN_TEST_NAME_(testCaseName, testName)<SEQAN_TParam>::runTest()
351351

352+
// --------------------------------------------------------------------------
353+
// Macro SEQAN_TEST_EXCEPTION()
354+
// --------------------------------------------------------------------------
355+
356+
#define SEQAN_TEST_EXCEPTION(_exception_type, command) \
357+
do \
358+
{ \
359+
bool caughtException = false; \
360+
try \
361+
{ \
362+
command; \
363+
} \
364+
catch(_exception_type& ex) \
365+
{ \
366+
caughtException = true; \
367+
} \
368+
catch(...) \
369+
{ \
370+
SEQAN_FAIL("Wrong exception thrown: %s", #_exception_type); \
371+
} \
372+
if (!caughtException) \
373+
SEQAN_FAIL("No exception thrown!"); \
374+
} while(false)
375+
376+
#define SEQAN_TEST_EXCEPTION_WITH_MESSAGE(_exception_type, command, _message) \
377+
do \
378+
{ \
379+
bool caughtException = false; \
380+
try \
381+
{ \
382+
command; \
383+
} \
384+
catch(_exception_type& ex) \
385+
{ \
386+
if(std::string(ex.what()) != _message) \
387+
SEQAN_FAIL("Got correct exception but wrong message: '%s' != '%s'", ex.what(), _message); \
388+
caughtException = true; \
389+
} \
390+
catch(...) \
391+
{ \
392+
SEQAN_FAIL("Wrong exception thrown: %s", #_exception_type); \
393+
} \
394+
if (!caughtException) \
395+
SEQAN_FAIL("No exception thrown!"); \
396+
} while(false)
397+
398+
352399
} // namespace seqan
353400

354401
#endif // #ifndef CORE_INCLUDE_SEQAN_BASIC_TEST_SYSTEM_H_

core/include/seqan/gff_io/gff_io_base.h

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ namespace seqan {
6767
..include:seqan/gff_io.h
6868
*/
6969

70-
// TODO(singer): const should be non const, but is const elsewhere
7170
struct TagGff_;
7271
typedef Tag<TagGff_> Gff;
7372

@@ -88,7 +87,6 @@ typedef Tag<TagGff_> Gff;
8887
..include:seqan/gff_io.h
8988
*/
9089

91-
// TODO(singer): const should be non const, but is const elsewhere
9290
struct TagGtf_;
9391
typedef Tag<TagGtf_> Gtf;
9492

@@ -306,11 +304,9 @@ template <typename TForwardIter, typename TKeyString, typename TValueString>
306304
inline void
307305
_parseReadGffKeyValue(TValueString & outValue, TKeyString & key, TForwardIter & iter)
308306
{
309-
IsWhitespace isWhitespace;
310-
311307
//TODO(singer): AssertList functor would be need
312308
char c = value(iter);
313-
if (c == ' ' || c == '\t' || c == '\n' || c == '=')
309+
if (IsWhitespace()(c) || c == '=')
314310
{
315311
throw std::runtime_error("The key field of an attribute is empty!");
316312
return; // Key cannot be empty.
@@ -319,8 +315,7 @@ _parseReadGffKeyValue(TValueString & outValue, TKeyString & key, TForwardIter &
319315
for (; !atEnd(iter); goNext(iter))
320316
{
321317
c = value(iter);
322-
//if (IsWhitespace(c) || c == '=' || c == ';')
323-
if (c == '\n' || c == '\r' || c == ' ' || c == '=' || c == ';')
318+
if (IsNewline()(c) || c == ' ' || c == '=' || c == ';')
324319
break;
325320
appendValue(key, c);
326321
}
@@ -330,35 +325,35 @@ _parseReadGffKeyValue(TValueString & outValue, TKeyString & key, TForwardIter &
330325
return;
331326
}
332327

333-
if(value(iter) == '\r' || value(iter) == '\n')
328+
if (IsNewline()(value(iter)))
334329
return;
335330

336331
skipUntil(iter, NotFunctor<IsWhitespace>());
337332

338333
if (value(iter) == '=')
339334
{
340335
skipOne(iter);
336+
skipUntil(iter, NotFunctor<IsWhitespace>());
341337
}
342338

343339
if (value(iter) == '"')
344340
{
345341
// Handle the case of a string literal.
346342
skipOne(iter);
343+
skipUntil(iter, NotFunctor<IsWhitespace>());
347344
readUntil(outValue, iter, OrFunctor<EqualsChar<'"'>, AssertFunctor<NotFunctor<IsNewline>, ParseError, Gff> >());
348345
skipOne(iter);
349346

350347
// Go over the trailing semicolon and any trailing space.
351-
while (!atEnd(iter) && (value(iter) == ';' || value(iter) == ' '))
352-
goNext(iter);
348+
skipUntil(iter, NotFunctor<OrFunctor<EqualsChar<';'>, EqualsChar<' '> > >());
353349
}
354350
else
355351
{
356352
// Read until the first semicolon, return at whitespace.
357353
readUntil(outValue, iter, OrFunctor<EqualsChar<';'>, IsNewline>());
358354

359355
// Skip semicolon and spaces if any.
360-
while (!atEnd(iter) && (value(iter) == ';' || value(iter) == ' '))
361-
goNext(iter);
356+
skipUntil(iter, NotFunctor<OrFunctor<EqualsChar<';'>, EqualsChar<' '> > >());
362357
}
363358
return;
364359
}
@@ -430,8 +425,6 @@ inline void clear(GffRecord & record)
430425
..include:seqan/gff_io.h
431426
*/
432427

433-
//TODO(singer): no checking if record is complete
434-
//TODO(singer): no checking whether lexicalCast is working
435428
template <typename TFwdIterator>
436429
inline void
437430
_readGffRecord(GffRecord & record, TFwdIterator & iter, GffContext & context)
@@ -483,31 +476,19 @@ _readGffRecord(GffRecord & record, TFwdIterator & iter, GffContext & context)
483476
skipOne(iter, IsTab());
484477

485478
// read column 7: strand
486-
//TODO(singer): readUntil taking a char would be good!
487-
//TODO(singer): readOne
488-
record.strand = value(iter);
489-
if (record.strand != '-' &&record.strand != '+')
490-
{
491-
record.strand = '.';
492-
}
493-
skipOne(iter);
479+
readOne(record.strand, iter, OrFunctor<OrFunctor<EqualsChar<'-'>, EqualsChar<'+'> >, EqualsChar<'.'> >());
494480
skipOne(iter, IsTab());
495481

496482
// read column 8: phase
497-
record.phase = value(iter);
498-
if (record.phase != '0' && record.phase != '1' && record.phase != '2')
499-
{
500-
record.phase = '.';
501-
}
502-
skipOne(iter);
503-
skipOne(iter, IsTab());
504-
483+
readOne(record.phase, iter, OrFunctor<OrFunctor<EqualsChar<'0'>, EqualsChar<'1'> >, OrFunctor<EqualsChar<'2'>, EqualsChar<'.'> > >());
484+
505485
// It's fine if there are no attributes and the line ends here.
506486
if (atEnd(iter) || isNewline(value(iter)))
507487
{
508488
skipLine(iter);
509489
return;
510490
}
491+
skipOne(iter, IsTab());
511492

512493
// read column 9: attributes
513494
while (!atEnd(iter))
@@ -611,7 +592,7 @@ _writePossiblyInQuotes(TTarget& target, TString & source, TMustBeQuotedFunctor c
611592
for (TIter it = begin(source, Standard()); it != itEnd; ++it)
612593
{
613594
// we have a problem if the string contains a '"' or a line break
614-
if (*it == '\n' || *it == '"')
595+
if (value(it) =='\n' || value(it) == '"')
615596
throw std::runtime_error("Attribute contains illegal character!");
616597

617598
if (func(*it))
@@ -757,13 +738,9 @@ _writeRecordImpl(TTarget & target, GffRecord const & record, TSeqId const & ref,
757738

758739
// write column 2: source
759740
if (empty(record.source))
760-
{
761741
writeValue(target, '.');
762-
}
763742
else
764-
{
765743
write(target, record.source);
766-
}
767744
writeValue(target, '\t');
768745

769746
// write column 3: type

core/include/seqan/graph_align/graph_algorithm_refine_align.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ _getSeqBeginAndEnd(Align<TAliSource,TAliSpec> & segment,
109109
// 50000 _getRefinedMatchScore Functions
110110
////////////////////////////////////////////////////////////////////////////////////////
111111
////////////////////////////////
112+
113+
//TODO(singer): Remove this forward
114+
template <typename T>
115+
struct Row;
116+
112117
//for Align<TAliSource,TAliSpec>
113118
//get score for alignment of length len starting at pos_i on first sequence
114119
//and pos_j on second sequence

core/include/seqan/graph_types/graph_utility_parsing.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ namespace SEQAN_NAMESPACE_MAIN
4848
//////////////////////////////////////////////////////////////////////////////
4949

5050
// This is unused and a deletion candidate.
51+
// TODO(singer): Remove this!
52+
/*
5153
template<typename TPath, typename TStringSet, typename TNames>
5254
inline unsigned int
5355
_loadSequences(TPath const& in_path,
@@ -85,7 +87,7 @@ _loadSequences(TPath const& in_path,
8587
8688
return count;
8789
}
88-
90+
*/
8991

9092
}// namespace SEQAN_NAMESPACE_MAIN
9193

core/include/seqan/score.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <seqan/score/score_base.h>
4545
#include <seqan/score/score_edit.h>
4646
#include <seqan/score/score_matrix.h>
47-
#include <seqan/score/score_matrix_io.h>
47+
//#include <seqan/score/score_matrix_io.h>
4848
#include <seqan/score/score_matrix_data.h>
4949
#include <seqan/score/score_simple.h>
5050

core/include/seqan/seq_io/fasta_fastq.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
// Input/Output on FASTA and FASTQ files.
3636
// ==========================================================================
3737

38-
#ifndef SEQAN_SEQ_IO_READ_FASTA_FASTQ_H_
39-
#define SEQAN_SEQ_IO_READ_FASTA_FASTQ_H_
38+
#ifndef SEQAN_SEQ_IO_FASTA_FASTQ_H_
39+
#define SEQAN_SEQ_IO_FASTA_FASTQ_H_
4040

4141
namespace seqan {
4242

@@ -97,7 +97,7 @@ struct SequenceOutputOptions
9797
SequenceOutputOptions(int lineLength = -1, bool qualMeta = false) :
9898
lineLength(lineLength),
9999
qualMeta(qualMeta)
100-
{}
100+
{}
101101
};
102102

103103
// ----------------------------------------------------------------------------
@@ -293,4 +293,4 @@ inline void writeRecord(TTarget & target,
293293

294294
} // namespace seqan
295295

296-
#endif // #ifndef SEQAN_SEQ_IO_READ_FASTA_FASTQ_H_
296+
#endif // #ifndef SEQAN_SEQ_IO_FASTA_FASTQ_H_

core/include/seqan/sequence/iterator_range.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ value(Range<TIterator> const & range, TPos pos)
275275
// ----------------------------------------------------------------------------
276276

277277
template <typename TIterator>
278-
SEQAN_HOST_DEVICE inline typename Difference<Range<TIterator> >::Type
278+
SEQAN_HOST_DEVICE inline typename Size<Range<TIterator> >::Type
279279
length(Range<TIterator> const & range)
280280
{
281281
return range.end - range.begin;

0 commit comments

Comments
 (0)