source: trunk/test/gff.cc @ 2483

Last change on this file since 2483 was 2483, checked in by Peter, 12 years ago

adding missing include

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1// $Id: gff.cc 2483 2011-04-25 14:02:55Z peter $
2
3/*
4  Copyright (C) 2011 Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "Suite.h"
23
24#include "yat/omic/GFF2.h"
25#include "yat/omic/GFF3.h"
26
27#include <cassert>
28#include <fstream>
29
30using namespace theplu::yat;
31using namespace omic;
32
33template<typename T>
34void avoid_pedantic_warning(T t) {}
35
36void gff2(test::Suite&);
37void gff3(test::Suite&);
38
39template<class T>
40void test_gff(test::Suite&, GFF&);
41
42int main(int argc, char* argv[])
43{
44  test::Suite suite(argc, argv);
45
46  gff2(suite);
47  gff3(suite);
48
49  return suite.return_value();
50}
51
52
53void test_gff(test::Suite& suite, GFF& gff)
54{
55  std::string seqid = gff.seqid();
56  std::string source = gff.source();
57  std::string type = gff.type();
58  avoid_pedantic_warning<const std::string&>(gff.start());
59  avoid_pedantic_warning<const std::string&>(gff.end());
60  avoid_pedantic_warning<const std::string&>(gff.score());
61  avoid_pedantic_warning<const std::string&>(gff.strand());
62  avoid_pedantic_warning<const std::string&>(gff.phase());
63  const std::map<std::string, std::string>& m = gff.attributes();
64  avoid_pedantic_warning(m);
65}
66
67void gff2(test::Suite& suite)
68{
69  suite.out() << "testing GFF2\n";
70  std::ifstream is(test::filename("data/small.gff2").c_str());
71  assert(is);
72  GFF2 gff2;
73  suite.add(getline(is, gff2));
74  test_gff(suite, gff2);
75  const std::string& a = gff2.attribute("genotype");
76  if (!suite.add(a=="T or C"))
77    suite.err() << "incorrect genotype value: `" << a << "'\n"
78                << "expected: `T or C'\n";
79  is.close();
80}
81
82void gff3(test::Suite& suite)
83{
84  suite.out() << "testing GFF3\n";
85  std::ifstream is(test::filename("data/small.gff3").c_str());
86  assert(is);
87  GFF3 gff3;
88  if (!suite.add(getline(is, gff3)))
89    suite.err() << "getline failed\n";
90  test_gff(suite, gff3);
91  const std::string& a = gff3.attribute("genotype");
92  if (!suite.add(a=="T"))
93    suite.err() << "incorrect genotype value: `" << a << "'\n"
94                << "expected: `T'\n";
95  is.close();
96}
Note: See TracBrowser for help on using the repository browser.