This file is indexed.

/usr/include/libGenome-1.3/libGenome/gnMultiSpec.h is in libgenome-1.3-0-dev 1.3.1-3build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
/////////////////////////////////////////////////////////////////////////////
// File:            gnMultiSpec.h
// Purpose:         multiple spec template class
// Description:     Template for specs which can contain multiple data sources
// 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 _gnMultiSpec_h_
#define _gnMultiSpec_h_

#include "libGenome/gnDefs.h"
#include "libGenome/gnException.h"

#include <vector>
#include <string>

#include "libGenome/gnClone.h"
#include "libGenome/gnBaseFeature.h"
#include "libGenome/gnBaseHeader.h"
#include "libGenome/gnBaseSpec.h"


namespace genome {

/**
 * This class defines an interface for specs which have multiple subspecs
 * containing sequence data.
 */
template< class SubSpec >
class GNDLLEXPORT gnMultiSpec : public gnBaseSpec
{
public:
	gnMultiSpec(){}
	/**
	 * Destructor, frees memory.
	 */
	virtual ~gnMultiSpec(){}
	virtual gnMultiSpec* Clone() const = 0;

// Base Spec stuff
	virtual gnSeqI GetLength() const;
	virtual void CropStart( gnSeqI cropLen );
	virtual void CropEnd( gnSeqI cropLen );

	virtual std::string GetSourceName() const;
	virtual void SetSourceName(const std::string& sourceName);
	virtual void Clear();

	virtual boolean SeqRead(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen, const uint32 contigI ) const;

//Multispec stuff
	/**
	 * Returns the number of subspecs this spec contains.
	 * @return The number of subspecs this spec contains.
	 */
	virtual uint32 GetSpecListLength() const;
	/**
	 * Get the spec at index i in the list of subspecs.
	 * @param i The index of the spec
	 * @return The spec.
	 */
	virtual SubSpec* GetSpec( const uint32 i ) const;
	/**
	 * Get the spec from the list of subspecs which contains the specified base pair.
	 * @param baseI The base pair index.
	 * @return The spec.
	 */
	virtual SubSpec* GetSpecByBase( const gnSeqI baseI ) const;
	/**
	 * Get the index of the subspec which contains the specified base pair.
	 * @param baseI The base pair index.
	 * @return The subspec index.
	 */
	virtual uint32 GetSpecIndexByBase( const gnSeqI baseI ) const;
	/**
	 * Get the index of the spec which has the given name.
	 * @param name The name of the spec to find.
	 * @return The spec index.
	 */
	virtual uint32 GetSpecIndexByName( const std::string& name ) const;
	/**
	 * Get the starting base pair, in this spec's sequence, of the given subspec.
	 * @param specI The subspec index.
	 * @return The subspec's starting base pair.
	 */
	virtual gnSeqI GetSpecStartBase( const uint32 specI ) const;
	/**
	 * Get the ending base pair, in this spec's sequence, of the given subspec.
	 * @param specI The subspec index.
	 * @return The subspec's ending base pair.
	 */
	virtual gnSeqI GetSpecEndBase( const uint32 specI ) const;
	/**
	 * Add a subspec to this spec.
	 * Throws an exception if the insertion index i is out of range
	 * @param spec The subspec to add.
	 * @param i The subspec to insert before
	 * @return True if successful
	 */
	virtual void AddSpec( SubSpec* spec, const uint32 i = UINT32_MAX );
	/**
	 * Remove a subspec from this spec.
	 * @param i The index of the subspec to remove.
	 */
	virtual void RemoveSpec( uint32 i );

	/**
	 * Returns the number of headers this spec contains.
	 * @return The number of headers this spec contains.
	 */
	virtual uint32 GetHeaderListLength() const;
	/**
	 * Add a header to this spec, adds to the end of the header list by default.
	 * @param head The header to add.
	 * @param i The header to insert before.  If i is larger than the size of the header list
	 * the header will be added to the end of the list.
	 */
	virtual void AddHeader( gnBaseHeader *head, const uint32 i = UINT32_MAX);
	/**
	 * Get the headers at index i in the list of headers.
	 * Throws a HeaderIndexOutOfBounds exception if a nonexistant header is referenced
	 * @param i The index of the header
	 * @return The header.
	 */
	virtual gnBaseHeader* GetHeader( const uint32 i ) const;
	/**
	 * Find the first header with the specified name, starting at index i.
	 * @param name The name of the header to find.
	 * @param i The index to start looking at.
	 * @return The header or NULL if none was found.
	 */
	virtual gnBaseHeader* GetHeader( const std::string& name, uint32& i) const;
	/**
	 * Remove a header from this spec.
	 * Throws a HeaderIndexOutOfBounds exception if a nonexistant header is referenced
	 * @param i The index of the header to remove.
	 */
	virtual void RemoveHeader( uint32 i );

	/**
	 * Add a feature to this spec.
	 * @param feat The feature to add.
	 * @return True if successful
	 */
	uint32 AddFeature( gnBaseFeature* feat );
	/**
	 * Returns the number of features this spec contains.
	 * @return The number of features this spec contains.
	 */
	virtual uint32 GetFeatureListLength() const = 0;
	/**
	 * Get the feature at index i in the list of features.
	 * @param i The index of the feature
	 * @return The feature.
	 */
	virtual gnBaseFeature* GetFeature( const uint32 i ) const = 0;
	/**
	 * Creates a list of all features which are contained by coordinates specified.
	 * @param lt The coordinates containing the features to return.
	 * @param feature_vector The std::vector to store features in.
	 * @param index_vector A std::vector of indices which correspond to the features.
	 */
	virtual void GetContainedFeatures(const gnLocation& lt, std::vector<gnBaseFeature*>& feature_vector, std::vector<uint32>& index_vector) const = 0;
	/**
	 * Creates a list of all features which intersect the coordinates specified.
	 * @param lt The coordinates intersecting the features to return.
	 * @param feature_vector The std::vector to store features in.
	 * @param index_vector A std::vector of indices which correspond to the features.
	 */
	virtual void GetIntersectingFeatures(const gnLocation& lt, std::vector<gnBaseFeature*>& feature_vector, std::vector<uint32>& index_vector) const = 0;
	/**
	 * Creates a list of features which may have been broken by an edit.
	 * @param lt The coordinates containing the features to return.
	 * @param feature_vector The std::vector to store features in.
	 */
	virtual void GetBrokenFeatures(const gnLocation& lt, std::vector<gnBaseFeature*>& feature_vector) const = 0;
	/**
	 * Remove a feature from this spec.
	 * @param i The index of the feature to remove.
	 * @return True if successful
	 */
	virtual void RemoveFeature( const uint32 i ) = 0;
	
protected:
	std::string m_sourceName;
	
	std::vector < SubSpec* > m_SpecList;
	std::vector < gnBaseHeader* > m_headerList;
private:

}; // class gnMultiSpec

template< class SubSpec >
inline
uint32 gnMultiSpec< SubSpec >::GetHeaderListLength() const
{
	return m_headerList.size();
}

template< class SubSpec >
inline
gnBaseHeader* gnMultiSpec< SubSpec >::GetHeader(const uint32 i) const
{
	if(i < m_headerList.size()){
		return m_headerList[i];
	}
	return 0;
}

template< class SubSpec >
inline
std::string gnMultiSpec< SubSpec >::GetSourceName() const{
	return m_sourceName;
}

template< class SubSpec >
inline
void gnMultiSpec< SubSpec >::SetSourceName(const std::string& sourceName){
	m_sourceName = sourceName;
}

template< class SubSpec >
uint32 gnMultiSpec< SubSpec >::GetSpecListLength() const{
	return m_SpecList.size();
}

template< class SubSpec >
SubSpec* gnMultiSpec< SubSpec >::GetSpec( const uint32 i ) const{
	if(i < m_SpecList.size())
		return m_SpecList[i];
	Throw_gnEx(FragmentIndexOutOfBounds());
}

template< class SubSpec >
SubSpec* gnMultiSpec< SubSpec >::GetSpecByBase( const gnSeqI baseI ) const{
	return m_SpecList[GetSpecIndexByBase(baseI)];
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::AddSpec( SubSpec* spec, const uint32 i ){
	uint32 index = i == UINT32_MAX ? m_SpecList.size() : i;
	if(index <= m_SpecList.size()){
		m_SpecList.insert(m_SpecList.begin() + index, spec);
	}
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::RemoveSpec( uint32 i ){
	if(i < GetSpecListLength()){
		m_SpecList.erase(m_SpecList.begin() + i);
	}
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::Clear()
{
	gnBaseSpec::Clear();
	uint32 list_size = m_headerList.size();
	for(uint32 i=0; i < list_size; i++)
		delete m_headerList[i];
	m_headerList.clear();
}

template< class SubSpec >
gnSeqI gnMultiSpec< SubSpec >::GetLength() const
{
	gnSeqI subLen = 0;	//aggregate the lower levels.
	for(uint32 i=0; i < GetSpecListLength(); i++)
		subLen += GetSpec(i)->GetLength();
	return subLen;
}

//Return the index of the subspec which contains the base in question
template< class SubSpec >
uint32 gnMultiSpec< SubSpec >::GetSpecIndexByBase( const gnSeqI baseI ) const{
	gnSeqI cur_length = 0;
	for(uint32 i=0; i < GetSpecListLength(); i++){
		cur_length += GetSpec(i)->GetLength();
		if(baseI < cur_length)
			return i;
	}
	//if we made it here then the base was out of bounds
	Throw_gnEx(SeqIndexOutOfBounds());
}

template< class SubSpec >
uint32 gnMultiSpec< SubSpec >::GetSpecIndexByName( const std::string& name ) const{
	for(uint32 i=0; i < GetSpecListLength(); i++){
		if(name == GetSpec(i)->GetName())
			return i;
	}
	Throw_gnEx(SpecIndexOutOfBounds());
}

//returns the starting base pair index of the given subspec.
template< class SubSpec >
gnSeqI gnMultiSpec< SubSpec >::GetSpecStartBase( const uint32 specI ) const{
	uint32 i;
	if(specI >= GetSpecListLength())
		Throw_gnEx(SpecIndexOutOfBounds());
	
	gnSeqI start_base = 0;
	for(i=0; i < specI; i++){
		start_base += GetSpec(i)->GetLength();
	}
	return start_base;
}

template< class SubSpec >
gnSeqI gnMultiSpec< SubSpec >::GetSpecEndBase( const uint32 specI ) const{
	uint32 i;
	if(specI >= GetSpecListLength())
		Throw_gnEx(SpecIndexOutOfBounds());
	
	gnSeqI end_base = 0;
	for(i=0; i <= specI; i++){
		end_base += GetSpec(i)->GetLength();
	}
	return end_base;
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::CropStart( gnSeqI cropLen ){
	gnSeqI curbase = 0;
	for(uint32 specI = 0; specI < GetSpecListLength(); specI++){
		curbase += GetSpec(specI)->GetLength();
		if(curbase <= cropLen){
			//delete the spec completely
			gnBaseSpec *tmp_spec = GetSpec(specI);
			RemoveSpec(specI);
			delete tmp_spec;
			specI--;
		}else{
			//recurse and break
			gnSeqI sub_len = cropLen - (curbase - GetSpec(specI)->GetLength());
			GetSpec(specI)->CropStart(sub_len);
			break;
		}
	}
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::CropEnd( gnSeqI cropLen ){
	gnSeqI curbase = 0;
	gnSeqI cropbase = GetLength() - cropLen;  //last base to keep
	boolean trash_the_rest = false;
	for(uint32 specI = 0; specI < GetSpecListLength(); specI++){
		curbase += GetSpec(specI)->GetLength();		
		if(trash_the_rest){
			//delete the spec entirely
			gnBaseSpec *tmp_spec = GetSpec(specI);
			RemoveSpec(specI);
			delete tmp_spec;
			specI--;
			continue;
		}else if(curbase > cropbase){
			GetSpec(specI)->CropEnd(curbase - cropbase);
			trash_the_rest = true;
		}else if(curbase == cropbase)
			trash_the_rest = true;
	}
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::AddHeader( gnBaseHeader* head, const uint32 i) 
{
	uint32 index = i == UINT32_MAX ? m_headerList.size() : i;
	m_headerList.insert(m_headerList.begin() + index, head);
}

template< class SubSpec >
gnBaseHeader* gnMultiSpec< SubSpec >::GetHeader( const std::string& name, uint32& i) const{
	for(; i < m_headerList.size(); i++){
		if( m_headerList[i]->GetHeaderName() == name)
			return m_headerList[i];
	}
	Throw_gnEx(HeaderIndexOutOfBounds());
}

template< class SubSpec >
void gnMultiSpec< SubSpec >::RemoveHeader( uint32 i) 
{
	if(i <= m_headerList.size()){
		m_headerList.erase(m_headerList.begin() + i);
	}
	Throw_gnEx(HeaderIndexOutOfBounds());
}

template< class SubSpec >
boolean gnMultiSpec< SubSpec >::SeqRead(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen, const uint32 contigI ) const{
	if( bufLen == 0 )
		return true;
	if(contigI == ALL_CONTIGS){
		gnSeqI curpos = 0;
		gnSeqI readBytes = 0;
		gnSeqI remainingBytes = bufLen;
		uint32 curSpecI = 0;
		//seek to start spec.
		for(curSpecI=0; curSpecI < GetSpecListLength(); curSpecI++){
			curpos += GetSpec(curSpecI)->GetLength();
			if(curpos > start)
				break;
		}
		if(curpos <= start)
			Throw_gnEx(SeqIndexOutOfBounds());
		//read until we're done;
		while((remainingBytes > 0) && (curSpecI < GetSpecListLength())) {
			gnSeqI readable = GetSpec(curSpecI)->GetLength();
			//check for circular
			gnSeqI start_pos = readBytes == 0 ? start - (curpos - readable) : 0;
			gnSeqI to_read = readable - start_pos >= remainingBytes ? remainingBytes : readable - start_pos;
			boolean success = GetSpec(curSpecI)->SeqRead(start_pos, buf+readBytes, to_read, contigI);

			readBytes += to_read;
			remainingBytes -= to_read;
			if(!success)
				break;
			curSpecI++;
		}
		bufLen = readBytes;
		return true;
	}else{	//read from the specified contig.
		if(contigI < GetSpecListLength())
			return GetSpec(contigI)->SeqRead(start, buf, bufLen, ALL_CONTIGS);
		else
			Throw_gnEx(SpecIndexOutOfBounds());
	}
	return false;
}




}	// end namespace genome

#endif
	// _gnMultiSpec_h_