27
27
28
28
import org .bridgedb .DataSource ;
29
29
import org .bridgedb .Xref ;
30
- import org .bridgedb .bio .BioDataSource ;
31
30
import org .pathvisio .core .debug .Logger ;
32
31
33
32
/**
34
- * Exports to pathway format understood by the EuGene
35
- * pathway statistics program.
36
- * This format is basically a list of genes in a flat text file
33
+ * Exports to pathway format understood by the EuGene pathway statistics
34
+ * program. This format is basically a list of genes in a flat text file
37
35
* preceded by 3 header lines.
38
36
*
39
- * EuGene supports several id systems but has its own naming
40
- * for them, this exporter also handles the translation.
37
+ * EuGene supports several id systems but has its own naming for them, this
38
+ * exporter also handles the translation.
41
39
*/
42
- public class EUGeneExporter implements PathwayExporter
43
- {
40
+ public class EUGeneExporter implements PathwayExporter {
44
41
public String [] getExtensions () {
45
42
return new String [] { "pwf" };
46
43
}
@@ -53,7 +50,7 @@ public void doExport(File file, Pathway pathway) throws ConverterException {
53
50
EUGenePathway eugPathway = new EUGenePathway (pathway );
54
51
try {
55
52
eugPathway .writeToEUGene (file );
56
- } catch (Exception e ) {
53
+ } catch (Exception e ) {
57
54
throw new ConverterException (e );
58
55
}
59
56
}
@@ -62,11 +59,11 @@ private static class EUGenePathway {
62
59
Logger log = Logger .log ;
63
60
Pathway pathway ;
64
61
65
- DataSource system ; //The annotation system
62
+ DataSource system ; // The annotation system
66
63
67
64
List <Xref > refs ;
68
65
69
- public EUGenePathway (Pathway p ) {
66
+ public EUGenePathway (Pathway p ) {
70
67
pathway = p ;
71
68
read ();
72
69
}
@@ -77,30 +74,27 @@ void writeToEUGene(File file) throws FileNotFoundException {
77
74
StringBuilder missedGenes = new StringBuilder ();
78
75
euGeneSystem = getEUGeneSystem ();
79
76
80
- for (Xref ref : refs )
81
- {
77
+ for (Xref ref : refs ) {
82
78
DataSource ds = ref .getDataSource ();
83
79
String id = ref .getId ();
84
- if (ds == system )
85
- { //Check if gene is of most occuring system
80
+ if (ds == system ) { // Check if gene is of most occuring system
86
81
geneString .append (id + "\n " );
87
- }
88
- else
89
- {
82
+ } else {
90
83
missedGenes .append (id + "|" + ds .getSystemCode () + "; " );
91
84
log .error ("id '" + id + "' differs from pathway annotation system" );
92
85
}
93
86
}
94
87
95
- //Write the file
88
+ // Write the file
96
89
PrintStream out = null ;
97
90
out = new PrintStream (file );
98
91
99
- //Print the data
92
+ // Print the data
100
93
out .println ("//PATHWAY_NAME = " + pathway .getMappInfo ().getMapInfoName ());
101
94
out .println ("//PATHWAY_SOURCE = GenMAPP" );
102
95
out .println ("//PATHWAY_MARKER = " + euGeneSystem );
103
- if (missedGenes .length () > 0 ) out .println ("//LOST_DURING_CONVERSION: " + missedGenes );
96
+ if (missedGenes .length () > 0 )
97
+ out .println ("//LOST_DURING_CONVERSION: " + missedGenes );
104
98
out .print (geneString );
105
99
106
100
out .close ();
@@ -110,105 +104,79 @@ void read() {
110
104
refs = new ArrayList <Xref >();
111
105
Map <DataSource , Integer > codeCount = new HashMap <DataSource , Integer >();
112
106
113
- for (PathwayElement elm : pathway .getDataObjects ()) {
114
- if (elm .getObjectType () != ObjectType .DATANODE ) {
115
- continue ; //Skip non-datanodes
107
+ for (PathwayElement elm : pathway .getDataObjects ()) {
108
+ if (elm .getObjectType () != ObjectType .DATANODE ) {
109
+ continue ; // Skip non-datanodes
116
110
}
117
111
Xref ref = elm .getXref ();
118
112
DataSource ds = ref .getDataSource ();
119
- if (ref == null || ref .getId ().equals ("" ) || ref .getDataSource () == null )
120
- {
121
- continue ; //Skip datanodes with incomplete annotation
113
+ if (ref == null || ref .getId ().equals ("" ) || ref .getDataSource () == null ) {
114
+ continue ; // Skip datanodes with incomplete annotation
122
115
}
123
- refs .add (ref );
116
+ refs .add (ref );
124
117
125
- //Increase code count for this code
126
- if (codeCount .containsKey (ref .getDataSource ()))
118
+ // Increase code count for this code
119
+ if (codeCount .containsKey (ref .getDataSource ()))
127
120
codeCount .put (ds , codeCount .get (ds ) + 1 );
128
- else codeCount .put (ds , 1 );
121
+ else
122
+ codeCount .put (ds , 1 );
129
123
}
130
124
131
- //Get most occuring systemcode
125
+ // Get most occuring systemcode
132
126
DataSource maxCode = null ;
133
- for (DataSource ds : codeCount .keySet ())
134
- {
135
- if (maxCode == null || codeCount .get (ds ) > codeCount .get (maxCode ))
136
- {
127
+ for (DataSource ds : codeCount .keySet ()) {
128
+ if (maxCode == null || codeCount .get (ds ) > codeCount .get (maxCode )) {
137
129
maxCode = ds ;
138
130
}
139
131
}
140
132
system = maxCode ;
141
133
142
- if (system == null ) { //May occur when no identifiers available
143
- system = BioDataSource . ENSEMBL ;
134
+ if (system == null ) { // May occur when no identifiers available
135
+ system = DataSource . getByCompactIdentifierPrefix ( "ensembl" ) ;
144
136
}
145
137
146
- if (codeCount .keySet ().size () > 1 ) {
147
- log .warn ("\t This pathway contains genes with different SystemCodes; '" +
148
- maxCode + "' has the highest occurence and is therefore chosen as PATHWAY_MARKER" +
149
- " for the EUGene file\n \t Other SystemCodes found and their occurences: "
150
- + codeCount );
138
+ if (codeCount .keySet ().size () > 1 ) {
139
+ log .warn ("\t This pathway contains genes with different SystemCodes; '" + maxCode
140
+ + "' has the highest occurence and is therefore chosen as PATHWAY_MARKER"
141
+ + " for the EUGene file\n \t Other SystemCodes found and their occurences: " + codeCount );
151
142
}
152
143
153
144
}
154
145
155
146
String getEUGeneSystem () {
156
- if (systemMappings .containsKey (system ))
157
- {
147
+ if (systemMappings .containsKey (system )) {
158
148
return systemMappings .get (system );
159
- }
160
- else
161
- {
149
+ } else {
162
150
return system .getFullName ();
163
151
}
164
152
}
165
153
}
166
154
167
155
private static Map <DataSource , String > systemMappings ;
168
- private static final String [] EU_GENE_SYSTEMS = new String []
169
- {
170
- "ENSEMBL_GENE_ID" ,
171
- "UNIPROT" ,
172
- "ENTREZ" ,
173
- "UNIGENE" ,
174
- "AFFYMETRIX" ,
175
- "AGILENT" ,
176
- "HGNC" ,
177
- "PDB_ID" ,
178
- "SGD_ID"
179
- };
180
- private static final DataSource [] GENMAPP_SYSTEMS = new DataSource []
181
- {
182
- BioDataSource .ENSEMBL ,
183
- BioDataSource .UNIPROT ,
184
- BioDataSource .ENTREZ_GENE ,
185
- BioDataSource .UNIGENE ,
186
- BioDataSource .AFFY ,
187
- BioDataSource .AGILENT ,
188
- BioDataSource .HUGO ,
189
- BioDataSource .PDB ,
190
- BioDataSource .SGD
191
- };
192
-
193
- static
194
- {
156
+ private static final String [] EU_GENE_SYSTEMS = new String [] { "ENSEMBL_GENE_ID" , "UNIPROT" , "ENTREZ" , "UNIGENE" ,
157
+ "AFFYMETRIX" , "AGILENT" , "HGNC" , "PDB_ID" , "SGD_ID" };
158
+ private static final DataSource [] GENMAPP_SYSTEMS = new DataSource [] {
159
+ DataSource .getByCompactIdentifierPrefix ("ensembl" ), DataSource .getByCompactIdentifierPrefix ("uniprot" ),
160
+ DataSource .getByCompactIdentifierPrefix ("ncbigene" ), DataSource .getByCompactIdentifierPrefix ("unigene" ),
161
+ DataSource .getByCompactIdentifierPrefix ("affy.probeset" ), DataSource .getExistingByFullName ("Agilent" ), // TODO
162
+ DataSource .getExistingByFullName ("HGNC" ), // TODO
163
+ DataSource .getByCompactIdentifierPrefix ("pdb" ), DataSource .getByCompactIdentifierPrefix ("sgd" ) };
164
+
165
+ static {
195
166
systemMappings = new HashMap <DataSource , String >();
196
- for (int i = 0 ; i < EU_GENE_SYSTEMS .length ; i ++)
197
- {
167
+ for (int i = 0 ; i < EU_GENE_SYSTEMS .length ; i ++) {
198
168
systemMappings .put (GENMAPP_SYSTEMS [i ], EU_GENE_SYSTEMS [i ]);
199
169
}
200
170
}
201
171
202
172
@ Override
203
- public List <String > getWarnings ()
204
- {
173
+ public List <String > getWarnings () {
205
174
return Collections .emptyList ();
206
175
}
207
176
208
177
@ Override
209
- public void doExport (File file , Pathway pathway , int zoom )
210
- throws ConverterException {
178
+ public void doExport (File file , Pathway pathway , int zoom ) throws ConverterException {
211
179
// TODO Auto-generated method stub
212
-
180
+
213
181
}
214
182
}
0 commit comments