File: Tsequence.cxx

package info (click to toggle)
phylonium 1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,340 kB
  • sloc: cpp: 15,701; ansic: 782; makefile: 139; python: 66; sh: 41
file content (42 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download | duplicates (3)
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
#include <string>
#include "catch.hpp"
#include "sequence.h"

TEST_CASE("Sequence basics")
{
	auto s = sequence("Name", "ACGTACGT");

	REQUIRE(s.get_name() == "Name");
	REQUIRE(s.get_nucl() == "ACGTACGT");
	REQUIRE(s.size() == 8);
}

TEST_CASE("Revcomp")
{
	REQUIRE(reverse("") == "");
	REQUIRE(reverse("A") == "T");
	REQUIRE(reverse("C") == "G");
	REQUIRE(reverse("G") == "C");
	REQUIRE(reverse("T") == "A");
	REQUIRE(reverse("ACGTACGT") == "ACGTACGT");

	auto str = std::string("TACGATCGATCGAAAGCTAGTTCGCCCCGAGATA");
	auto rc = "TATCTCGGGGCGAACTAGCTTTCGATCGATCGTA";
	REQUIRE(reverse(str) == rc);
	REQUIRE(reverse(reverse(str)) == str);
}

TEST_CASE("Filtering nucleotides")
{
	REQUIRE(filter_nucl("") == "");
	REQUIRE(filter_nucl("A") == "A");
	REQUIRE(filter_nucl("C") == "C");
	REQUIRE(filter_nucl("G") == "G");
	REQUIRE(filter_nucl("T") == "T");
	REQUIRE(filter_nucl("!") == "");

	auto str = std::string("TACGATCGATCGAAAGCTAGTTCGCCCCGAGATA");
	REQUIRE(filter_nucl(str) == str);

	REQUIRE(filter_nucl("tacgatc!gatc!gaa__agctagttcgcc#ccgagata") == str);
}