X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FDBRefFetcher.java;h=445c90acdb01c2469e03a7d79be358f45a3db590;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=bd3c73323de37914f913ad59e54ff34fb550b361;hpb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;p=jalview.git diff --git a/src/jalview/io/DBRefFetcher.java b/src/jalview/io/DBRefFetcher.java index bd3c733..445c90a 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; @@ -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); + } } } } @@ -353,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", @@ -371,5 +378,3 @@ public class DBRefFetcher implements Runnable } } } - -