File: gnStringSpec.h

package info (click to toggle)
libgenome 1.3.1-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,156 kB
  • ctags: 1,212
  • sloc: cpp: 10,910; sh: 8,264; makefile: 79
file content (108 lines) | stat: -rw-r--r-- 2,949 bytes parent folder | download | duplicates (8)
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
/////////////////////////////////////////////////////////////////////////////
// File:            gnStringSpec.h
// Purpose:         implements gnContigSpec for strings
// Description:     
// Changes:        
// Version:         libGenome 0.5.1 
// Author:          Aaron Darling 
// Modified by:     
// Copyright:       (c) Aaron Darling 
// Licenses:        See COPYING file for details 
/////////////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef _gnStringSpec_h_
#define _gnStringSpec_h_

#include "libGenome/gnDefs.h"

#include <cstdlib>
#include <cstring>
#include <string>
#include "libGenome/gnContigSpec.h"
#include "libGenome/gnBaseSource.h"

namespace genome {


/**
 * gnStringSpec stores a sequence and annotation data in memory.
 * For a more complete description see the gnBaseSpec documentation.
 */
class GNDLLEXPORT gnStringSpec : public gnContigSpec
{
public:
	/**
	 * Empty constructor.
	 */
	gnStringSpec();
	/**
	 * Constructor, creates a gnStringSpec using sequence data in the given std::string.
	 * A circular spec will be created if the end index is greater than the start.
	 * @param m_string The std::string to read base pairs from.
	 * @param startI The index to start reading base pairs from the std::string.
	 * @param endI The index to stop reading base pairs from the std::string.
	 * @param revComp True if the sequence is read reverse complement.
	 */
	gnStringSpec( const std::string& m_string, const gnSeqI startI=0, const gnSeqI endI=GNSEQI_END, const boolean revComp = false);
	/**
	 * Copy constructor.
	 * @param s the gnStringSpec to copy.
	 */
	gnStringSpec( const gnStringSpec& s );
	~gnStringSpec();
// Clone
	gnStringSpec* Clone() const;
	virtual void Clear();
// Value Access methods

	virtual gnSeqI GetSourceLength() const;

	
// Source Spec Specific functions
	virtual gnBaseSource *GetSource() const;

	/**
	 * Copies a specified range of bases and returns a pointer to
	 * the resulting gnStringSpec.  You must delete the copy when you
	 * are finished with it.
	 * @param startI The first base pair to copy
	 * @param len The length of the piece to copy
	 * @return A copy of the gnStringSpec containing only the specified bases
	 */
	virtual gnStringSpec* CloneRange( const gnSeqI startI, const gnSeqI len ) const;

protected:
	virtual boolean Read(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen ) const;
	std::string m_seqString;
	
}; // class gnStringSpec

inline
gnStringSpec* gnStringSpec::Clone() const
{
	return new gnStringSpec( *this );
}
inline
gnSeqI gnStringSpec::GetSourceLength() const{
	return m_seqString.length();
}
inline
gnBaseSource* gnStringSpec::GetSource() const
{
	return NULL;
}

inline
boolean gnStringSpec::Read(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen) const{
	memcpy(buf, m_seqString.data() + start, bufLen);
	return true;
}


}	// end namespace genome

#endif
	// _gnStringSpec_h_