File: testgnSequence.cpp

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 (100 lines) | stat: -rw-r--r-- 2,791 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
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "libGenome/gnSourceFactory.h"
#include "libGenome/gnFASSource.h"
#include "libGenome/gnSequence.h"

#include <iostream>

#include "libGenome/gnFilter.h"
#include "libGenome/gnStringTools.h"
#include "libGenome/gnFastTranslator.h"

int main( int32 argc, char* argv[])
{
	argc; argv;
try{
	string filename;
	cout << "Enter a filename to read bases from.\n";
	cin >> filename;
	cout << "Opening " + filename + "\n";
	gnSequence gpseq, gnsubseq;
	
//	string pathname = filename;
//	standarizePathString( pathname );
//	pathname = getPathString( pathname );
//	gnSourceFactory * msf = gnSourceFactory::GetSourceFactory();
//	msf->AddPath( pathname );
	gpseq.LoadSource(filename);
	cout << "Length " << gpseq.length() << " in " << gpseq.contigListSize() << " contigs\n";

	string pretrans, posttrans, posttrans2;
	const gnTranslator*  dna2pro_good = gnTranslator::DNAProteinTranslator();
	const gnFastTranslator*  dna2pro_fast = gnFastTranslator::DNAProteinTranslator();
	pretrans = gpseq.ToString();

	posttrans = pretrans;
	posttrans2 = pretrans;
	cout << "Doing correct translation:\n";
	dna2pro_good->Filter(posttrans);
	cout << "done\n";
	gnsubseq = posttrans;
	gnFASSource::Write(gnsubseq, "profile_good.fas");
	
//	posttrans = pretrans;
	cout << "Doing fast translation:\n";
	dna2pro_fast->Filter(posttrans2);
	cout << "done\n";
	gnsubseq = posttrans2;
	gnFASSource::Write(gnsubseq, "profile_fast.fas");


	cout << "base pairs 8 thru 68 are: \n";
	cout << gpseq.subseq(8, 60) << "\n";

	for(uint32 i=0; i < 15; i++){
		try{
			cout << "Contig " << i << " length " << gpseq.contig(i).length() << "\n";
		}catch(gnException& gne){
			cout << gne;
		}
	}
	cout << gpseq.subseq(1000000, 10);
	cin >> filename;

	gnSeqI midpoint = gpseq.length() / 2;
	gnSequence seqA = gpseq.subseq(1, midpoint);
	gnSequence seqB = gpseq.subseq(1 + midpoint, gpseq.length() - midpoint);
	cout << "Splitting " << gpseq.length() << " to " << seqA.length() << " and " << seqB.length() << "\n";
	cin >> filename;

	gnsubseq = gpseq.subseq(5, 10);
	cout << "subseq len: " << gnsubseq.length() << "\n";
	cout << "subseq: " << gnsubseq << "\n";
	gnSeqC* buf = new gnSeqC[gpseq.length()];
	gpseq.ToArray(buf, gpseq.length());

	cout << "Give a file name to output data: ";
	string outfilename;
	cin >> outfilename;
	gnFASSource::Write(gpseq, outfilename);
	
/*	gnSequence new_seq = gpseq.contig(3);
	cout << new_seq;
	new_seq += gpseq.contig(3);
	new_seq += gpseq.contig(2);
	new_seq += gpseq.contig(1);
	cout << new_seq;
	gnFASSource::Write(new_seq, outfilename);
	
*/	cout << "All done.  Contigs 3, 2, 1 are in " << outfilename << "\n";
	char bubba[50];
	cin >> bubba;
}catch(gnException& gne){
	cout << gne;
	string reality_bites;
	cin >> reality_bites;
}
}