X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FPdb.java%7E;fp=src%2Fjalview%2Fws%2Fdbsources%2FPdb.java%7E;h=0000000000000000000000000000000000000000;hb=17b7d054cf7faa5ee57ad8c8c4c9daa495d8cb35;hp=6c2f70ac6d01b82615eab3fc146ff343db12c65c;hpb=4a59f639cf5769d9ec66142ebecfa4961c5d3b04;p=jalview.git diff --git a/src/jalview/ws/dbsources/Pdb.java~ b/src/jalview/ws/dbsources/Pdb.java~ deleted file mode 100644 index 6c2f70a..0000000 --- a/src/jalview/ws/dbsources/Pdb.java~ +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ 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 - * 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 - * 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. - */ -package jalview.ws.dbsources; - -import jalview.api.FeatureSettingsModelI; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.DBRefSource; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.io.FormatAdapter; -import jalview.io.PDBFeatureSettings; -import jalview.util.MessageManager; -import jalview.ws.ebi.EBIFetchClient; - -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import com.stevesoft.pat.Regex; - -/** - * @author JimP - * - */ -public class Pdb extends EbiFileRetrievedProxy -{ - public Pdb() - { - super(); - } - - public static final String FEATURE_INSERTION = "INSERTION"; - - public static final String FEATURE_RES_NUM = "RESNUM"; - - private static String currentDefaultFormat = DBRefSource.PDB; - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getAccessionSeparator() - */ - @Override - public String getAccessionSeparator() - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getAccessionValidator() - */ - @Override - public Regex getAccessionValidator() - { - return new Regex("([1-9][0-9A-Za-z]{3}):?([ _A-Za-z0-9]?)"); - } - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getDbSource() - */ - @Override - public String getDbSource() - { - return DBRefSource.PDB; - } - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getDbVersion() - */ - @Override - public String getDbVersion() - { - return "0"; - } - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[]) - */ - @Override - public AlignmentI getSequenceRecords(String queries) throws Exception - { - AlignmentI pdbAlignment = null; - Vector result = new Vector(); - String chain = null; - String id = null; - if (queries.indexOf(":") > -1) - { - chain = queries.substring(queries.indexOf(":") + 1); - id = queries.substring(0, queries.indexOf(":")); - } - else - { - id = queries; - } - if (queries.length() > 4 && chain == null) - { - chain = queries.substring(4, 5); - id = queries.substring(0, 4); - } - if (!isValidReference(id)) - { - System.err.println("Ignoring invalid pdb query: '" + id + "'"); - stopQuery(); - return null; - } - String ext = getCurrentDefaultFormat().equalsIgnoreCase("mmcif") ? ".cif" - : ".xml"; - EBIFetchClient ebi = new EBIFetchClient(); - file = ebi.fetchDataAsFile("pdb:" + id, -<<<<<<< HEAD - getCurrentDefaultFomart().toLowerCase(), ext) -======= - getCurrentDefaultFormat().toLowerCase(), "raw", ext) ->>>>>>> develop - .getAbsolutePath(); - stopQuery(); - if (file == null) - { - return null; - } - try - { - - pdbAlignment = new FormatAdapter().readFile(file, - jalview.io.AppletFormatAdapter.FILE, - getCurrentDefaultFormat()); - if (pdbAlignment != null) - { - List toremove = new ArrayList(); - for (SequenceI pdbcs : pdbAlignment.getSequences()) - { - String chid = null; - // Mapping map=null; - for (PDBEntry pid : pdbcs.getAllPDBEntries()) - { - if (pid.getFile() == file) - { - chid = pid.getChainCode(); - - } - ; - - } - if (chain == null - || (chid != null && (chid.equals(chain) - || chid.trim().equals(chain.trim()) || (chain - .trim().length() == 0 && chid.equals("_"))))) - { - pdbcs.setName(jalview.datamodel.DBRefSource.PDB + "|" + id - + "|" + pdbcs.getName()); - // Might need to add more metadata to the PDBEntry object - // like below - /* - * PDBEntry entry = new PDBEntry(); // Construct the PDBEntry - * entry.setId(id); if (entry.getProperty() == null) - * entry.setProperty(new Hashtable()); - * entry.getProperty().put("chains", pdbchain.id + "=" + - * sq.getStart() + "-" + sq.getEnd()); - * sq.getDatasetSequence().addPDBId(entry); - */ - // Add PDB DB Refs - // We make a DBRefEtntry because we have obtained the PDB file from - // a - // verifiable source - // JBPNote - PDB DBRefEntry should also carry the chain and mapping - // information - DBRefEntry dbentry = new DBRefEntry(getDbSource(), - getDbVersion(), (chid == null ? id : id + chid)); - // dbentry.setMap() - pdbcs.addDBRef(dbentry); - } - else - { - // mark this sequence to be removed from the alignment - // - since it's not from the right chain - toremove.add(pdbcs); - } - } - // now remove marked sequences - for (SequenceI pdbcs : toremove) - { - pdbAlignment.deleteSequence(pdbcs); - if (pdbcs.getAnnotation() != null) - { - for (AlignmentAnnotation aa : pdbcs.getAnnotation()) - { - pdbAlignment.deleteAnnotation(aa); - } - } - } - } - - if (pdbAlignment == null || pdbAlignment.getHeight() < 1) - { - throw new Exception(MessageManager.formatMessage( - "exception.no_pdb_records_for_chain", new String[] { id, - ((chain == null) ? "' '" : chain) })); - } - - } catch (Exception ex) // Problem parsing PDB file - { - stopQuery(); - throw (ex); - } - return pdbAlignment; - } - - /* - * (non-Javadoc) - * - * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String) - */ - @Override - public boolean isValidReference(String accession) - { - Regex r = getAccessionValidator(); - return r.search(accession.trim()); - } - - /** - * obtain human glyoxalase chain A sequence - */ - @Override - public String getTestQuery() - { - return "1QIPA"; - } - - @Override - public String getDbName() - { - return "PDB"; // getDbSource(); - } - - @Override - public int getTier() - { - return 0; - } - - public static String getCurrentDefaultFormat() - { - return currentDefaultFormat; - } - - public static void setCurrentDefaultFormat(String currentDefaultFomart) - { - Pdb.currentDefaultFormat = currentDefaultFomart; - } - - /** - * Returns a descriptor for suitable feature display settings with - *
    - *
  • ResNums or insertions features visible
  • - *
  • insertions features coloured red
  • - *
  • ResNum features coloured by label
  • - *
  • Insertions displayed above (on top of) ResNums
  • - *
- */ - @Override - public FeatureSettingsModelI getFeatureColourScheme() - { - return new PDBFeatureSettings(); - } -}