File: sequence.hpp

package info (click to toggle)
mothur 1.48.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,692 kB
  • sloc: cpp: 161,866; makefile: 122; sh: 31
file content (116 lines) | stat: -rwxr-xr-x 3,000 bytes parent folder | download | duplicates (2)
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
#ifndef SEQUENCE_H
#define SEQUENCE_H

/*
 *  sequence.h
 *  
 *
 *  Created by Pat Schloss on 12/15/08.
 *  Copyright 2008 Patrick D. Schloss. All rights reserved.
 *
 *	A sequence object has three components: i) an accession number / name, ii) the unaligned primary sequence, iii) a
 *	pairwise aligned sequence, and iv) a sequence that is aligned to a reference alignment.  This class has methods
 *	to set and get these values for the other classes where they are needed.  *
 *
 */


//Data Structure for a fasta file.

#include "mothurout.h"
#include "utils.hpp"
#include "writer.h"

class Protein;

/**************************************************************************************************/

class Sequence {
    
#ifdef UNIT_TEST
    friend class TestSequence;
#endif

    
public:
    
	Sequence();
	Sequence(string, string);
	Sequence(ifstream&);
    Sequence(ifstream&, string&, bool);
	Sequence(istringstream&);
    #ifdef USE_BOOST
    Sequence(boost::iostreams::filtering_istream&);
    #endif
    ~Sequence() = default;
	
	void setName(string);
    string getName();
	void setUnaligned(string);
    string getUnaligned();
	void setAligned(string);
    string getAligned();
    void setComment(string);
    string getComment();
	void setPairwise(string);
	string getPairwise();
    Protein getProtein(int, bool); //starting frame, trim
    Protein getProtein(); //assumes starting frame 1, trim=false
    bool isAligned();
	
	string getInlineSeq();
    int getNumNs();
	int getNumBases();
	int getStartPos();
	int getEndPos();
    
    void reverseComplement();
    void trim(int);
	void padToPos(int);
	void padFromPos(int);
    int filterToPos(int); //any character before the pos is changed to . and aligned and unaligned strings changed
    int filterFromPos(int); //any character after the pos is changed to . and aligned and unaligned strings changed
	int getAlignLength();
	int getAmbigBases();
	void removeAmbigBases();
	int getLongHomoPolymer();
    string convert2ints();
    
	void printSequence(ostream&);
    void printSequence(OutputWriter*);
    void printUnAlignedSequence(ostream&);
    
	
protected:
    
	MothurOut* m;
	void initialize();
	string getSequenceString(ifstream&, int&);
	string getCommentString(ifstream&);
	string getSequenceString(istringstream&, int&);
	string getCommentString(istringstream&);
    string getSequenceName(ifstream&);
    #ifdef USE_BOOST
    string getCommentString(boost::iostreams::filtering_istream&);
    string getSequenceString(boost::iostreams::filtering_istream&, int&);
    string getSequenceName(boost::iostreams::filtering_istream&);
    #endif
    string getSequenceName(istringstream&);
    
    
	string name;
	string unaligned;
	string aligned;
	string pairwise;
    string comment;
	int numBases;
	int alignmentLength;
	int longHomoPolymer;
	int ambigBases;
	int startPos, endPos;
    Utils util;
};

/**************************************************************************************************/

#endif