From: Charles Ofoegbu Date: Mon, 20 Oct 2014 08:39:40 +0000 (+0100) Subject: Modified SequenceFetcher to include Intermine as a data source X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f1085ed7e6ff0b81ed91dec50d00950384c089db;p=jalview.git Modified SequenceFetcher to include Intermine as a data source --- diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..633e9a1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto + +#settings for Windows users +core.autocrlf = true + +#settings for Mac users +#core.autocrlf = input \ No newline at end of file diff --git a/src/jalview/datamodel/DBRefSource.java b/src/jalview/datamodel/DBRefSource.java index 1af18b6..993bec8 100755 --- a/src/jalview/datamodel/DBRefSource.java +++ b/src/jalview/datamodel/DBRefSource.java @@ -1,19 +1,19 @@ /* * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors - * + * * This file is part of Jalview. - * + * * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License + * 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. - * - * Jalview 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 + * + * Jalview 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 Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. @@ -24,9 +24,9 @@ package jalview.datamodel; * Defines internal constants for unambiguous annotation of DbRefEntry source * strings and describing the data retrieved from external database sources (see * jalview.ws.DbSourcProxy) - * + * * @author JimP - * + * */ public class DBRefSource { @@ -36,6 +36,12 @@ public class DBRefSource public static String UNIPROT = "UNIPROT"; /** + * INTERMINE Accession Number + */ + public static String INTERMINE = "INTERMINE"; + + + /** * UNIPROT Entry Name */ public static String UP_NAME = "UNIPROT_NAME"; @@ -79,22 +85,22 @@ public class DBRefSource * List of databases whose sequences might have coding regions annotated */ public static final String[] DNACODINGDBS = - { EMBL, EMBLCDS, GENEDB }; + { EMBL, EMBLCDS, GENEDB }; public static final String[] CODINGDBS = - { EMBLCDS, GENEDB }; + { EMBLCDS, GENEDB }; public static final String[] PROTEINDBS = - { UNIPROT, PDB, UNIPROTKB }; + { UNIPROT, PDB, UNIPROTKB }; public static final String[] PROTEINSEQ = - { UNIPROT, UNIPROTKB }; + { UNIPROT, UNIPROTKB }; public static final String[] PROTEINSTR = - { PDB }; + { PDB }; public static final String[] DOMAINDBS = - { PFAM, RFAM }; + { PFAM, RFAM }; /** * set of unique DBRefSource property constants. These could be used to diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index caf5b5e..1c9e6c1 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -1,19 +1,19 @@ /* * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors - * + * * This file is part of Jalview. - * + * * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License + * 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. - * - * Jalview 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 + * + * Jalview 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 Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. @@ -38,7 +38,7 @@ import java.util.Vector; * and abstract class in jalview.ws.seqfetcher. This implements the run-time * discovery of sequence database clients, and provides a hardwired main for * testing all registered handlers. - * + * */ public class SequenceFetcher extends ASequenceFetcher { @@ -46,7 +46,7 @@ public class SequenceFetcher extends ASequenceFetcher * Thread safe construction of database proxies TODO: extend to a configurable * database plugin mechanism where classes are instantiated by reflection and * queried for their DbRefSource and version association. - * + * */ public SequenceFetcher() { @@ -67,6 +67,7 @@ public class SequenceFetcher extends ASequenceFetcher // PFAM addDBRefSourceImpl(jalview.ws.dbsources.RfamFull.class); addDBRefSourceImpl(jalview.ws.dbsources.RfamSeed.class); + addDBRefSourceImpl(jalview.ws.dbsources.Intermine.class); if (addDas) { registerDasSequenceSources(); @@ -81,11 +82,11 @@ public class SequenceFetcher extends ASequenceFetcher { String[] srcs = this.getSupportedDb(); ArrayList dassrc = new ArrayList(), nondas = new ArrayList(); - for (int i = 0; i < srcs.length; i++) + for (String src : srcs) { boolean das = false, skip = false; String nm; - for (DbSourceProxy dbs : getSourceProxy(srcs[i])) + for (DbSourceProxy dbs : getSourceProxy(src)) { // Skip the alignment databases for the moment - they're not useful for // verifying a single sequence against its reference source @@ -96,7 +97,7 @@ public class SequenceFetcher extends ASequenceFetcher else { nm = dbs.getDbName(); - if (getSourceProxy(srcs[i]) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) + if (getSourceProxy(src) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) { if (nm.startsWith("das:")) { @@ -113,11 +114,11 @@ public class SequenceFetcher extends ASequenceFetcher } if (das) { - dassrc.add(srcs[i]); + dassrc.add(src); } else { - nondas.add(srcs[i]); + nondas.add(src); } } String[] tosort = nondas.toArray(new String[0]), sorted = nondas @@ -158,24 +159,24 @@ public class SequenceFetcher extends ASequenceFetcher { String[] srcs = this.getSupportedDb(); ArrayList dassrc = new ArrayList(), nondas = new ArrayList(); - for (int i = 0; i < srcs.length; i++) + for (String src : srcs) { - for (DbSourceProxy dbs : getSourceProxy(srcs[i])) + for (DbSourceProxy dbs : getSourceProxy(src)) { String nm = dbs.getDbName(); - if (getSourceProxy(srcs[i]) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) + if (getSourceProxy(src) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) { if (nm.startsWith("das:")) { nm = nm.substring(4); } dassrc.add(new String[] - { srcs[i], nm.toUpperCase() }); + { src, nm.toUpperCase() }); } else { nondas.add(new String[] - { srcs[i], nm.toUpperCase() }); + { src, nm.toUpperCase() }); } } } @@ -214,7 +215,7 @@ public class SequenceFetcher extends ASequenceFetcher /** * simple run method to test dbsources. - * + * * @param argv */ public static void main(String[] argv) @@ -238,7 +239,7 @@ public class SequenceFetcher extends ASequenceFetcher if (argv != null && argv.length > 0) { List sps = new SequenceFetcher(withDas) - .getSourceProxy(argv[0]); + .getSourceProxy(argv[0]); if (sps != null) { @@ -280,12 +281,13 @@ public class SequenceFetcher extends ASequenceFetcher } ASequenceFetcher sfetcher = new SequenceFetcher(withDas); String[] dbSources = sfetcher.getSupportedDb(); - for (int dbsource = 0; dbsource < dbSources.length; dbsource++) + for (String db : dbSources) { - String db = dbSources[dbsource]; // skip me if (db.equals(DBRefSource.PDB)) + { continue; + } for (DbSourceProxy sp : sfetcher.getSourceProxy(db)) { System.out.println("Source: " + sp.getDbName() + " (" + db @@ -301,8 +303,8 @@ public class SequenceFetcher extends ASequenceFetcher DBRefSource.DNACODINGSEQDB) || sp.getDbSourceProperties().containsKey( DBRefSource.DNASEQDB) - || sp.getDbSourceProperties().containsKey( - DBRefSource.CODINGSEQDB); + || sp.getDbSourceProperties().containsKey( + DBRefSource.CODINGSEQDB); // try and find products String types[] = jalview.analysis.CrossRef .findSequenceXrefTypes(dna, al.getSequencesArray()); @@ -310,12 +312,12 @@ public class SequenceFetcher extends ASequenceFetcher { System.out.println("Xref Types for: " + (dna ? "dna" : "prot")); - for (int t = 0; t < types.length; t++) + for (String type : types) { - System.out.println("Type: " + types[t]); + System.out.println("Type: " + type); SequenceI[] prod = jalview.analysis.CrossRef .findXrefSequences(al.getSequencesArray(), dna, - types[t]).getSequencesArray(); + type).getSequencesArray(); System.out.println("Found " + ((prod == null) ? "no" : "" + prod.length) + " products"); @@ -332,8 +334,8 @@ public class SequenceFetcher extends ASequenceFetcher else { noProds.addElement((dna ? new Object[] - { al, al } : new Object[] - { al })); + { al, al } : new Object[] + { al })); } } @@ -348,9 +350,13 @@ public class SequenceFetcher extends ASequenceFetcher System.out.println("ERROR:No alignment retrieved."); StringBuffer raw = sp.getRawRecords(); if (raw != null) + { System.out.println(raw.toString()); + } else + { System.out.println("ERROR:No Raw results."); + } } else { @@ -366,7 +372,7 @@ public class SequenceFetcher extends ASequenceFetcher if (ds == null) { ds = new Alignment(new SequenceI[] - { sq }); + { sq }); } else diff --git a/src/jalview/ws/dbsources/Intermine.java b/src/jalview/ws/dbsources/Intermine.java new file mode 100644 index 0000000..65ce5c9 --- /dev/null +++ b/src/jalview/ws/dbsources/Intermine.java @@ -0,0 +1,102 @@ +package jalview.ws.dbsources; + +import jalview.datamodel.AlignmentI; +import jalview.datamodel.DBRefSource; +import jalview.ws.seqfetcher.DbSourceProxy; +import jalview.ws.seqfetcher.DbSourceProxyImpl; + +import com.stevesoft.pat.Regex; + +public class Intermine extends DbSourceProxyImpl implements DbSourceProxy +{ + + @Override + public String getDbSource() + { + return DBRefSource.INTERMINE; + } + + @Override + public String getDbName() + { + return "Intermine"; + } + + @Override + public String getDbVersion() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getAccessionSeparator() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Regex getAccessionValidator() + { + // TODO Auto-generated method stub + return null; + } + + // @Override + // public Hashtable getDbSourceProperties() + // { + // // TODO Auto-generated method stub + // return null; + // } + + @Override + public String getTestQuery() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isValidReference(String accession) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public AlignmentI getSequenceRecords(String queries) throws Exception + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean queryInProgress() + { + // TODO Auto-generated method stub + return false; + } + + @Override + public StringBuffer getRawRecords() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isA(Object dbsourceproperty) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getTier() + { + // TODO Auto-generated method stub + return 0; + } + +}