-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMappedOrthogroup.C
140 lines (123 loc) · 3.04 KB
/
MappedOrthogroup.C
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
/*
Arboretum: An algorithm to cluster functional genomesomics data from multiple species
Copyright (C) 2013 Sushmita Roy sushroy@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <iostream>
#include "GeneMap.H"
#include "MappedOrthogroup.H"
MappedOrthogroup::MappedOrthogroup()
{
cnts=0;
}
MappedOrthogroup::~MappedOrthogroup()
{
}
int
MappedOrthogroup::setMembers(map<string,string>& speciesGeneMap)
{
map<string,string>* geneSet=new map<string,string>;
int setid=geneSets.size();
geneSets[setid]=geneSet;
for(map<string,string>::iterator sIter=speciesGeneMap.begin();sIter!=speciesGeneMap.end();sIter++)
{
(*geneSet)[sIter->first]=sIter->second;
GeneMap* speciesHit_s=NULL;
if(orthoMembers.find(sIter->first)==orthoMembers.end())
{
speciesHit_s=new GeneMap;
orthoMembers[sIter->first]=speciesHit_s;
}
else
{
speciesHit_s=orthoMembers[sIter->first];
}
if(speciesGeneMap.size()==1)
{
speciesHit_s->addPair(sIter->second,"","");
}
map<string,string>::iterator tIter=sIter;
tIter++;
for(;tIter!=speciesGeneMap.end();tIter++)
{
GeneMap* speciesHit_t=NULL;
speciesHit_s->addPair(sIter->second,tIter->first,tIter->second);
if(orthoMembers.find(tIter->first)==orthoMembers.end())
{
speciesHit_t=new GeneMap;
orthoMembers[tIter->first]=speciesHit_t;
}
else
{
speciesHit_t=orthoMembers[tIter->first];
}
speciesHit_t->addPair(tIter->second,sIter->first,sIter->second);
}
}
return 0;
}
int
MappedOrthogroup::setID(int aid)
{
oid=aid;
return 0;
}
int
MappedOrthogroup::getID()
{
return oid;
}
map<string,GeneMap*>&
MappedOrthogroup::getOrthoMembers()
{
return orthoMembers;
}
int
MappedOrthogroup::incrCnt()
{
cnts=cnts+1;
return 0;
}
int
MappedOrthogroup::getCnt()
{
return cnts;
}
GeneMap*
MappedOrthogroup::getSpeciesHits(const char* specName)
{
string key(specName);
if(orthoMembers.find(key)==orthoMembers.end())
{
return NULL;
}
return orthoMembers[key];
}
STRINTMAP*
MappedOrthogroup::getSpeciesHitsForGene(const char* srcSpecName, const char* targetSpecName, const char* geneName)
{
string key(srcSpecName);
if(orthoMembers.find(key)==orthoMembers.end())
{
cout <<"No hits for species " << srcSpecName << endl;
return NULL;
}
GeneMap* geneMap=orthoMembers[key];
STRINTMAP* hits=geneMap->getHits(geneName,targetSpecName);
return hits;
}
map<int,map<string,string>*>&
MappedOrthogroup::getGeneSets()
{
return geneSets;
}