File: clustering.cpp

package info (click to toggle)
cufflinks 1.3.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 3,864 kB
  • sloc: cpp: 48,999; ansic: 12,297; sh: 3,381; python: 432; makefile: 209
file content (130 lines) | stat: -rw-r--r-- 2,995 bytes parent folder | download
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
/*
 *  clustering.cpp
 *  cufflinks
 *
 *  Created by Cole Trapnell on 3/15/10.
 *  Copyright 2010 Cole Trapnell. All rights reserved.
 *
 */

#include "clustering.h"

void ConnectByExonOverlap::operator()(const AbundanceGroup& cluster,
									  AbundanceGraph& G)
{
	const vector<shared_ptr<Abundance> >& abundances = cluster.abundances();
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		add_vertex(G);
	}
	
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		shared_ptr<Scaffold> scaff_i = abundances[i]->transfrag();
		assert (scaff_i);
		
		for (size_t j = i + 1; j < abundances.size(); ++j)
		{
			shared_ptr<Scaffold> scaff_j = abundances[j]->transfrag();
			assert (scaff_j);
			
			if (Scaffold::exons_overlap(*scaff_i, *scaff_j))
				add_edge(i, j, G);
		}
	}
}

void ConnectByAnnotatedGeneId::operator()(const AbundanceGroup& cluster,
										  AbundanceGraph& G)
{
	const vector<shared_ptr<Abundance> >& abundances = cluster.abundances();
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		add_vertex(G);
	}
	
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		set<string> i_gene_id = abundances[i]->gene_id();
		for (size_t j = i + 1; j < abundances.size(); ++j)
		{
			set<string> j_gene_id = abundances[j]->gene_id();
			if (i_gene_id == j_gene_id)
			{
				add_edge(i, j, G);
			}
		}
	}
}

void ConnectByAnnotatedTssId::operator()(const AbundanceGroup& cluster,
										  AbundanceGraph& G)
{
	const vector<shared_ptr<Abundance> >& abundances = cluster.abundances();
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		add_vertex(G);
	}
	
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		set<string> i_tss_id = abundances[i]->tss_id();
		for (size_t j = i + 1; j < abundances.size(); ++j)
		{
			set<string> j_tss_id = abundances[j]->tss_id();
			if (i_tss_id == j_tss_id)
			{
				add_edge(i, j, G);
			}
		}
	}
}

void ConnectByAnnotatedProteinId::operator()(const AbundanceGroup& cluster,
											 AbundanceGraph& G)
{
	const vector<shared_ptr<Abundance> >& abundances = cluster.abundances();
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		add_vertex(G);
	}
	
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		set<string> i_p_id = abundances[i]->protein_id();
		for (size_t j = i + 1; j < abundances.size(); ++j)
		{
			set<string> j_p_id = abundances[j]->protein_id();
			if (i_p_id == j_p_id)
			{
				add_edge(i, j, G);
			}
		}
	}
}

void ConnectByStrand::operator()(const AbundanceGroup& cluster,
								 AbundanceGraph& G)
{
	const vector<shared_ptr<Abundance> >& abundances = cluster.abundances();
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		add_vertex(G);
	}
	
	for (size_t i = 0; i < abundances.size(); ++i)
	{
		shared_ptr<Scaffold> scaff_i = abundances[i]->transfrag();
		assert (scaff_i);
		
		for (size_t j = i + 1; j < abundances.size(); ++j)
		{
			shared_ptr<Scaffold> scaff_j = abundances[j]->transfrag();
			assert (scaff_j);
			if (scaff_i->strand() == scaff_j->strand())
			{
				add_edge(i, j, G);
			}
		}
	}
}