X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FDBRefFetcher.java;h=437fee78e54368c08951ac37449a3f0ca1f0ff1a;hb=c39e588784c0fbb64c7dabfcae8db4faedde10e6;hp=4a6044fe0a2fc8b0c5c624d19feec8759de88737;hpb=06ebfc088d873bcd41d6a7cd5b57c54d859974f9;p=jalview.git diff --git a/src/jalview/io/DBRefFetcher.java b/src/jalview/io/DBRefFetcher.java index 4a6044f..437fee7 100644 --- a/src/jalview/io/DBRefFetcher.java +++ b/src/jalview/io/DBRefFetcher.java @@ -1,37 +1,31 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* 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 2 -* 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, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.io; -import jalview.datamodel.*; - -import jalview.gui.*; - import java.io.*; - import java.util.*; -import org.exolab.castor.mapping.Mapping; - +import org.exolab.castor.mapping.*; import org.exolab.castor.xml.*; -import jalview.analysis.AlignSeq; - - +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.gui.*; /** * DOCUMENT ME! @@ -39,7 +33,8 @@ import jalview.analysis.AlignSeq; * @author $author$ * @version $Revision$ */ -public class DBRefFetcher implements Runnable +public class DBRefFetcher + implements Runnable { AlignmentI dataset; AlignFrame af; @@ -60,7 +55,7 @@ public class DBRefFetcher implements Runnable try { // 1. Load the mapping information from the file - Mapping map = new Mapping(uni.getClass().getClassLoader()); + org.exolab.castor.mapping.Mapping map = new org.exolab.castor.mapping.Mapping(uni.getClass().getClassLoader()); java.net.URL url = getClass().getResource("/uniprot_mapping.xml"); map.loadMapping(url); @@ -73,10 +68,9 @@ public class DBRefFetcher implements Runnable } catch (Exception e) { - System.out.println("Error getUniprotEntries() "+e); + System.out.println("Error getUniprotEntries() " + e); } - return uni.getUniprotEntries(); } @@ -98,13 +92,16 @@ public class DBRefFetcher implements Runnable thread.start(); running = true; - if(waitTillFinished) + if (waitTillFinished) { - while(running) + while (running) { - try{ + try + { Thread.sleep(500); - }catch(Exception ex){} + } + catch (Exception ex) + {} } } @@ -122,15 +119,15 @@ public class DBRefFetcher implements Runnable key = key.toUpperCase(); Vector seqs; - if(seqRefs.containsKey(key)) + if (seqRefs.containsKey(key)) { - seqs = (Vector)seqRefs.get(key); + seqs = (Vector) seqRefs.get(key); - if(seqs!=null && !seqs.contains(seq)) + if (seqs != null && !seqs.contains(seq)) { seqs.addElement(seq); } - else if(seqs==null) + else if (seqs == null) { seqs = new Vector(); seqs.addElement(seq); @@ -146,7 +143,6 @@ public class DBRefFetcher implements Runnable seqRefs.put(key, seqs); } - /** * DOCUMENT ME! */ @@ -171,35 +167,39 @@ public class DBRefFetcher implements Runnable seqIndex++, i++) { Sequence sequence = (Sequence) sequences.get(seqIndex); - DBRefEntry [] uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(), new String[] { + DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs(sequence. + getDBRef(), new String[] + { jalview.datamodel.DBRefSource.UNIPROT}); - if (uprefs!=null) + if (uprefs != null) { - if(uprefs.length+i>50) + if (uprefs.length + i > 50) + { break; + } - for(int j=0; j50) + if (st.countTokens() + i > 50) { //Dont send more than 50 id strings to dbFetch!! - seqIndex --; + seqIndex--; } else { - while(st.hasMoreTokens()) - { - String token = st.nextToken(); - addSeqId(sequence, token); - queryString.append(token+";"); - } + while (st.hasMoreTokens()) + { + String token = st.nextToken(); + addSeqId(sequence, token); + queryString.append(token + ";"); + } } } } @@ -233,13 +233,12 @@ public class DBRefFetcher implements Runnable } af.setProgressBar("DBRef search completed", startTime); - // promptBeforeBlast(); + // promptBeforeBlast(); - running = false; + running = false; } - /** * DOCUMENT ME! * @@ -250,7 +249,9 @@ public class DBRefFetcher implements Runnable void ReadUniprotFile(File file) { if (!file.exists()) + { return; + } SequenceI sequence = null; @@ -275,7 +276,9 @@ public class DBRefFetcher implements Runnable { sequence = (SequenceI) seqs.elementAt(jj); if (!sequenceMatches.contains(sequence)) + { sequenceMatches.addElement(sequence); + } } } } @@ -289,7 +292,9 @@ public class DBRefFetcher implements Runnable { sequence = (SequenceI) seqs.elementAt(jj); if (!sequenceMatches.contains(sequence)) + { sequenceMatches.addElement(sequence); + } } } } @@ -305,7 +310,8 @@ public class DBRefFetcher implements Runnable System.out.println("Adding dbref to " + sequence.getName() + " : " + entry.getAccession().elementAt(0).toString()); - String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence()). + String nonGapped = AlignSeq.extractGaps("-. ", + sequence.getSequenceAsString()). toUpperCase(); int absStart = entry.getUniprotSequence().getContent().indexOf( @@ -352,7 +358,9 @@ public class DBRefFetcher implements Runnable { PDBEntry pdb = (PDBEntry) e.nextElement(); if (!pdb.getType().equals(DBRefSource.PDB)) + { continue; + } sequence.addDBRef(new DBRefEntry(DBRefSource.PDB, "0", @@ -370,5 +378,3 @@ public class DBRefFetcher implements Runnable } } } - -