ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/cuffcompare/test_load.cpp
Revision: 20
Committed: Mon Jul 18 21:08:36 2011 UTC (8 years, 3 months ago) by gpertea
File size: 2170 byte(s)
Log Message:
added cuffcompare sources

Line File contents
1 #include "GArgs.h"
2 #include "GStr.h"
3 #include "gtf_tracking.h"
4
5 GList<GSeqData> ref_data(true,true,true); //list of reference mRNAs and loci data for each genomic seq
6 //each locus will keep track of any superloci which includes it, formed during the analysis
7
8 int main(int argc, char * const argv[]) {
9 GArgs args(argc, argv, "FCRPq:r:o:");
10 GList<GSeqData>* rnas;
11 args.startNonOpt();
12 GStr gtfile(args.nextNonOpt());
13 if (gtfile.is_empty()) GError("Usage: test_load [-R] [{-P|-o <outgff>}] <gff_input>\nNo input GFF file given!\n");
14 gtf_tracking_verbose=true;
15 FILE* RNA_file=fopen(gtfile.chars(), "rb");
16 if (RNA_file==NULL) GError("Error opening file %s!\n",gtfile.chars());
17 //read_transcripts(mRNA_file, rnas, true);
18 bool load_as_ref=(args.getOpt('R')!=NULL);
19 if (load_as_ref) {
20 rnas=&ref_data;
21 read_mRNAs(RNA_file, *rnas, NULL, true, -1, gtfile.chars());
22 }
23 else {
24 rnas=new GList<GSeqData>(true,true,true);
25 read_mRNAs(RNA_file, *rnas, &ref_data, true, 0, gtfile.chars());
26 }
27 fclose(RNA_file);
28 int fcount=0;
29 int rcount=0;
30 int ucount=0;
31 for (int i=0;i<rnas->Count();i++) {
32 fcount+=rnas->Get(i)->mrnas_f.Count();
33 rcount+=rnas->Get(i)->mrnas_r.Count();
34 ucount+=rnas->Get(i)->umrnas.Count();
35 }
36 int mtotal=fcount+rcount+ucount;
37 GStr oname(args.getOpt('o'));
38 FILE* fout=NULL;
39 if (!oname.is_empty()) fout=fopen(oname.chars(), "w");
40 else if (args.getOpt('P')) fout=stdout;
41 GMessage("Totals:\n%6d on forward strand\n"
42 "%6d on reverse strand\n%6d unknown strand\n"
43 "--------------------------\n%6d total\n",
44 fcount, rcount, ucount, mtotal);
45 if (fout) {
46 for (int i=0;i<rnas->Count();i++) {
47 for (int k=0;k<rnas->Get(i)->mrnas_f.Count();k++) {
48 rnas->Get(i)->mrnas_f[k]->printGff(fout);
49 }
50 for (int k=0;k<rnas->Get(i)->mrnas_r.Count();k++) {
51 rnas->Get(i)->mrnas_r[k]->printGff(fout);
52 }
53 for (int k=0;k<rnas->Get(i)->umrnas.Count();k++) {
54 rnas->Get(i)->umrnas[k]->printGff(fout);
55 }
56 }
57 if (fout!=stdout) fclose(fout);
58 }
59 if (!load_as_ref) delete rnas;
60 }