2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.sifts;
23 import jalview.analysis.AlignSeq;
24 import jalview.api.DBRefEntryI;
25 import jalview.api.SiftsClientI;
26 import jalview.datamodel.DBRefEntry;
27 import jalview.datamodel.DBRefSource;
28 import jalview.datamodel.SequenceI;
29 import jalview.schemes.ResidueProperties;
30 import jalview.structure.StructureMapping;
31 import jalview.util.Format;
32 import jalview.xml.binding.sifts.Entry;
33 import jalview.xml.binding.sifts.Entry.Entity;
34 import jalview.xml.binding.sifts.Entry.Entity.Segment;
35 import jalview.xml.binding.sifts.Entry.Entity.Segment.ListMapRegion.MapRegion;
36 import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue;
37 import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.CrossRefDb;
38 import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.ResidueDetail;
39 import jalview.xml.binding.sifts.Entry.ListDB.Db;
42 import java.io.FileInputStream;
43 import java.io.FileNotFoundException;
44 import java.io.FileOutputStream;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.io.PrintStream;
49 import java.net.URLConnection;
50 import java.nio.file.Files;
51 import java.nio.file.Path;
52 import java.nio.file.attribute.BasicFileAttributes;
53 import java.util.ArrayList;
54 import java.util.Arrays;
55 import java.util.Collection;
56 import java.util.Collections;
57 import java.util.Date;
58 import java.util.HashMap;
59 import java.util.HashSet;
60 import java.util.List;
61 import java.util.TreeMap;
62 import java.util.zip.GZIPInputStream;
64 import javax.xml.bind.JAXBContext;
65 import javax.xml.bind.JAXBException;
66 import javax.xml.bind.Unmarshaller;
67 import javax.xml.stream.FactoryConfigurationError;
68 import javax.xml.stream.XMLInputFactory;
69 import javax.xml.stream.XMLStreamException;
70 import javax.xml.stream.XMLStreamReader;
73 import MCview.PDBChain;
74 import MCview.PDBfile;
76 public class SiftsClient implements SiftsClientI
78 private Entry siftsEntry;
84 private String structId;
86 private String segStartEnd;
88 private CoordinateSys seqCoordSys = CoordinateSys.UNIPROT;
90 private static final int BUFFER_SIZE = 4096;
92 public static final int UNASSIGNED = -1;
94 private static final int PDB_RES_POS = 0;
96 private static final int PDB_ATOM_POS = 1;
98 private static final String NOT_FOUND = "Not_Found";
100 private static final String NOT_OBSERVED = "Not_Observed";
102 private static final String SIFTS_FTP_BASE_URL = "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
104 private final static String NEWLINE = System.lineSeparator();
106 private final static int THRESHOLD_IN_DAYS = 2;
108 private String curSourceDBRef;
110 private HashSet<String> curDBRefAccessionIdsString;
112 public enum CoordinateSys
114 UNIPROT("UniProt"), PDB("PDBresnum"), PDBe("PDBe");
117 private CoordinateSys(String name)
122 public String getName()
128 public enum ResidueDetailType
130 NAME_SEC_STRUCTURE("nameSecondaryStructure"), CODE_SEC_STRUCTURE(
131 "codeSecondaryStructure"), ANNOTATION("Annotation");
134 private ResidueDetailType(String code)
139 public String getCode()
146 * Fetch SIFTs file for the given PDBfile and construct an instance of
150 * @throws SiftsException
152 public SiftsClient(PDBfile pdb) throws SiftsException
156 File siftsFile = getSiftsFile(pdbId);
157 siftsEntry = parseSIFTs(siftsFile);
161 * Construct an instance of SiftsClient using the supplied SIFTs file. Note:
162 * The SIFTs file should correspond to the PDB Id in PDBfile instance
166 * @throws SiftsException
169 public SiftsClient(PDBfile pdb, File siftsFile) throws SiftsException
173 siftsEntry = parseSIFTs(siftsFile);
177 * Parse the given SIFTs File and return a JAXB POJO of parsed data
180 * - the GZipped SIFTs XML file to parse
183 * if a problem occurs while parsing the SIFTs XML
185 private Entry parseSIFTs(File siftFile) throws SiftsException
187 try (InputStream in = new FileInputStream(siftFile);
188 GZIPInputStream gzis = new GZIPInputStream(in);)
190 // System.out.println("File : " + siftFile.getAbsolutePath());
191 JAXBContext jc = JAXBContext.newInstance("jalview.xml.binding.sifts");
192 XMLStreamReader streamReader = XMLInputFactory.newInstance()
193 .createXMLStreamReader(gzis);
194 Unmarshaller um = jc.createUnmarshaller();
195 return (Entry) um.unmarshal(streamReader);
196 } catch (JAXBException e)
199 throw new SiftsException(e.getMessage());
200 } catch (FileNotFoundException e)
203 throw new SiftsException(e.getMessage());
204 } catch (XMLStreamException e)
207 throw new SiftsException(e.getMessage());
208 } catch (FactoryConfigurationError e)
211 throw new SiftsException(e.getMessage());
212 } catch (IOException e)
215 throw new SiftsException(e.getMessage());
220 * Get a SIFTs XML file for a given PDB Id from Cache or download from FTP
221 * repository if not found in cache
224 * @return SIFTs XML file
225 * @throws SiftsException
227 public static File getSiftsFile(String pdbId) throws SiftsException
229 File siftsFile = new File(SiftsSettings.getSiftDownloadDirectory()
230 + pdbId.toLowerCase() + ".xml.gz");
231 if (siftsFile.exists())
233 // The line below is required for unit testing... don't comment it out!!!
234 System.out.println(">>> SIFTS File already downloaded for " + pdbId);
236 if (isFileOlderThanThreshold(siftsFile, THRESHOLD_IN_DAYS))
238 // System.out.println("Downloaded file is out of date, hence re-downloading...");
239 siftsFile = downloadSiftsFile(pdbId.toLowerCase());
243 siftsFile = downloadSiftsFile(pdbId.toLowerCase());
248 * This method enables checking if a cached file has exceeded a certain
254 * the threshold in days
257 public static boolean isFileOlderThanThreshold(File file, int noOfDays)
259 Path filePath = file.toPath();
260 BasicFileAttributes attr;
264 attr = Files.readAttributes(filePath, BasicFileAttributes.class);
265 diffInDays = (int) ((new Date().getTime() - attr.lastModifiedTime()
266 .toMillis()) / (1000 * 60 * 60 * 24));
267 // System.out.println("Diff in days : " + diffInDays);
268 } catch (IOException e)
272 return noOfDays <= diffInDays;
276 * Download a SIFTs XML file for a given PDB Id from an FTP repository
279 * @return downloaded SIFTs XML file
280 * @throws SiftsException
282 public static File downloadSiftsFile(String pdbId) throws SiftsException
284 String siftFile = pdbId + ".xml.gz";
285 String siftsFileFTPURL = SIFTS_FTP_BASE_URL + siftFile;
286 String downloadedSiftsFile = SiftsSettings.getSiftDownloadDirectory()
288 File siftsDownloadDir = new File(
289 SiftsSettings.getSiftDownloadDirectory());
290 if (!siftsDownloadDir.exists())
292 siftsDownloadDir.mkdirs();
296 // System.out.println(">> Download ftp url : " + siftsFileFTPURL);
297 URL url = new URL(siftsFileFTPURL);
298 URLConnection conn = url.openConnection();
299 InputStream inputStream = conn.getInputStream();
300 FileOutputStream outputStream = new FileOutputStream(
301 downloadedSiftsFile);
302 byte[] buffer = new byte[BUFFER_SIZE];
304 while ((bytesRead = inputStream.read(buffer)) != -1)
306 outputStream.write(buffer, 0, bytesRead);
308 outputStream.close();
310 // System.out.println(">>> File downloaded : " + downloadedSiftsFile);
311 } catch (IOException ex)
313 throw new SiftsException(ex.getMessage());
315 return new File(downloadedSiftsFile);
319 * Delete the SIFTs file for the given PDB Id in the local SIFTs download
323 * @return true if the file was deleted or doesn't exist
325 public static boolean deleteSiftsFileByPDBId(String pdbId)
327 File siftsFile = new File(SiftsSettings.getSiftDownloadDirectory()
328 + pdbId.toLowerCase() + ".xml.gz");
329 if (siftsFile.exists())
331 return siftsFile.delete();
337 * Get a valid SIFTs DBRef for the given sequence current SIFTs entry
340 * - the target sequence for the operation
341 * @return a valid DBRefEntry that is SIFTs compatible
343 * if no valid source DBRefEntry was found for the given sequences
345 public DBRefEntryI getValidSourceDBRef(SequenceI seq)
346 throws SiftsException
348 DBRefEntryI sourceDBRef = null;
349 sourceDBRef = seq.getSourceDBRef();
350 if (sourceDBRef != null && isValidDBRefEntry(sourceDBRef))
356 DBRefEntry[] dbRefs = seq.getDBRefs();
357 if (dbRefs == null || dbRefs.length < 1)
359 throw new SiftsException("Could not get source DB Ref");
362 for (DBRefEntryI dbRef : dbRefs)
364 if (dbRef == null || dbRef.getAccessionId() == null
365 || dbRef.getSource() == null)
369 if (isFoundInSiftsEntry(dbRef.getAccessionId())
370 && (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT) || dbRef
371 .getSource().equalsIgnoreCase(DBRefSource.PDB)))
377 if (sourceDBRef != null && isValidDBRefEntry(sourceDBRef))
381 throw new SiftsException("Could not get source DB Ref");
385 * Check that the DBRef Entry is properly populated and is available in this
386 * SiftClient instance
389 * - DBRefEntry to validate
390 * @return true validation is successful otherwise false is returned.
392 private boolean isValidDBRefEntry(DBRefEntryI entry)
394 return entry != null && entry.getAccessionId() != null
395 && isFoundInSiftsEntry(entry.getAccessionId());
399 public HashSet<String> getAllMappingAccession()
401 HashSet<String> accessions = new HashSet<String>();
402 List<Entity> entities = siftsEntry.getEntity();
403 for (Entity entity : entities)
405 List<Segment> segments = entity.getSegment();
406 for (Segment segment : segments)
408 List<MapRegion> mapRegions = segment.getListMapRegion()
410 for (MapRegion mapRegion : mapRegions)
412 accessions.add(mapRegion.getDb().getDbAccessionId());
420 public StructureMapping getSiftsStructureMapping(SequenceI seq,
421 String pdbFile, String chain) throws SiftsException
423 structId = (chain == null) ? pdbId : pdbId + "|" + chain;
424 System.out.println("Getting mapping for: " + pdbId + "|" + chain
425 + " : seq- " + seq.getName());
427 final StringBuilder mappingDetails = new StringBuilder(128);
428 PrintStream ps = new PrintStream(System.out)
431 public void print(String x)
433 mappingDetails.append(x);
437 public void println()
439 mappingDetails.append(NEWLINE);
442 HashMap<Integer, int[]> mapping = getGreedyMapping(chain, seq, ps);
444 String mappingOutput = mappingDetails.toString();
445 StructureMapping siftsMapping = new StructureMapping(seq, pdbFile,
446 pdbId, chain, mapping, mappingOutput);
451 public HashMap<Integer, int[]> getGreedyMapping(String entityId,
452 SequenceI seq, java.io.PrintStream os) throws SiftsException
454 ArrayList<Integer> omitNonObserved = new ArrayList<Integer>();
455 int nonObservedShiftIndex = 0;
456 System.out.println("Generating mappings for : " + entityId);
457 Entity entity = null;
458 entity = getEntityById(entityId);
459 String originalSeq = AlignSeq.extractGaps(
460 jalview.util.Comparison.GapChars, seq.getSequenceAsString());
461 HashMap<Integer, int[]> mapping = new HashMap<Integer, int[]>();
462 DBRefEntryI sourceDBRef = seq.getSourceDBRef();
463 if (sourceDBRef == null)
465 sourceDBRef = getValidSourceDBRef(seq);
466 // TODO ensure sequence start/end is in the same coordinate system and
467 // consistent with the choosen sourceDBRef
470 // set sequence coordinate system - default value is UniProt
471 if (sourceDBRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
473 seqCoordSys = CoordinateSys.PDB;
476 HashSet<String> dbRefAccessionIdsString = new HashSet<String>();
477 for (DBRefEntry dbref : seq.getDBRefs())
479 dbRefAccessionIdsString.add(dbref.getAccessionId().toLowerCase());
481 dbRefAccessionIdsString.add(sourceDBRef.getAccessionId().toLowerCase());
483 curDBRefAccessionIdsString = dbRefAccessionIdsString;
484 curSourceDBRef = sourceDBRef.getAccessionId();
486 TreeMap<Integer, String> resNumMap = new TreeMap<Integer, String>();
487 List<Segment> segments = entity.getSegment();
488 for (Segment segment : segments)
490 segStartEnd = segment.getStart() + " - " + segment.getEnd();
491 System.out.println("Mappging segments : " + segment.getSegId() + "\\"
493 List<Residue> residues = segment.getListResidue().getResidue();
494 for (Residue residue : residues)
496 int currSeqIndex = UNASSIGNED;
497 List<CrossRefDb> cRefDbs = residue.getCrossRefDb();
498 CrossRefDb pdbRefDb = null;
499 for (CrossRefDb cRefDb : cRefDbs)
501 if (cRefDb.getDbSource().equalsIgnoreCase(DBRefSource.PDB))
505 if (cRefDb.getDbCoordSys()
506 .equalsIgnoreCase(seqCoordSys.getName())
507 && isAccessionMatched(cRefDb.getDbAccessionId()))
509 String resNumIndexString = cRefDb.getDbResNum()
510 .equalsIgnoreCase("None") ? String.valueOf(UNASSIGNED)
511 : cRefDb.getDbResNum();
514 currSeqIndex = Integer.valueOf(resNumIndexString);
515 } catch (NumberFormatException nfe)
517 currSeqIndex = Integer.valueOf(resNumIndexString
518 .split("[a-zA-Z]")[0]);
520 if (pdbRefDb != null)
522 break;// exit loop if pdb and uniprot are already found
526 if (currSeqIndex == UNASSIGNED)
530 if (currSeqIndex > seq.getStart() && currSeqIndex <= seq.getEnd())
535 resNum = (pdbRefDb == null) ? Integer.valueOf(residue
536 .getDbResNum()) : Integer.valueOf(pdbRefDb
538 } catch (NumberFormatException nfe)
540 resNum = (pdbRefDb == null) ? Integer.valueOf(residue
541 .getDbResNum()) : Integer.valueOf(pdbRefDb
542 .getDbResNum().split("[a-zA-Z]")[0]);
545 if (isResidueObserved(residue)
546 || seqCoordSys == CoordinateSys.UNIPROT)
548 char resCharCode = ResidueProperties
549 .getSingleCharacterCode(ResidueProperties
550 .getCanonicalAminoAcid(residue.getDbResName()));
551 resNumMap.put(currSeqIndex, String.valueOf(resCharCode));
555 omitNonObserved.add(currSeqIndex);
556 ++nonObservedShiftIndex;
558 mapping.put(currSeqIndex - nonObservedShiftIndex, new int[] {
559 Integer.valueOf(resNum), UNASSIGNED });
565 populateAtomPositions(entityId, mapping);
566 } catch (Exception e)
570 if (seqCoordSys == CoordinateSys.UNIPROT)
572 padWithGaps(resNumMap, omitNonObserved);
574 int seqStart = UNASSIGNED;
575 int seqEnd = UNASSIGNED;
576 int pdbStart = UNASSIGNED;
577 int pdbEnd = UNASSIGNED;
579 Integer[] keys = mapping.keySet().toArray(new Integer[0]);
582 seqEnd = keys[keys.length - 1];
584 String matchedSeq = originalSeq;
585 if (seqStart != UNASSIGNED)
587 pdbStart = mapping.get(seqStart)[PDB_RES_POS];
588 pdbEnd = mapping.get(seqEnd)[PDB_RES_POS];
589 int orignalSeqStart = seq.getStart();
590 if (orignalSeqStart >= 1)
592 int subSeqStart = seqStart - orignalSeqStart;
593 int subSeqEnd = seqEnd - (orignalSeqStart - 1);
594 subSeqEnd = originalSeq.length() < subSeqEnd ? originalSeq.length()
596 matchedSeq = originalSeq.substring(subSeqStart, subSeqEnd);
600 StringBuilder targetStrucSeqs = new StringBuilder();
601 for (String res : resNumMap.values())
603 targetStrucSeqs.append(res);
608 MappingOutputPojo mop = new MappingOutputPojo();
609 mop.setSeqStart(seqStart);
610 mop.setSeqEnd(seqEnd);
611 mop.setSeqName(seq.getName());
612 mop.setSeqResidue(matchedSeq);
614 mop.setStrStart(pdbStart);
615 mop.setStrEnd(pdbEnd);
616 mop.setStrName(structId);
617 mop.setStrResidue(targetStrucSeqs.toString());
620 os.print(getMappingOutput(mop).toString());
626 * Checks if the residue instance is marked 'Not_observed' or not
631 private boolean isResidueObserved(Residue residue)
633 String annotation = getResidueAnnotaiton(residue,
634 ResidueDetailType.ANNOTATION);
635 if (annotation == null)
639 if (!annotation.equalsIgnoreCase(NOT_FOUND)
640 && annotation.equalsIgnoreCase(NOT_OBSERVED))
648 * Get annotation String for a given residue and annotation type
654 private String getResidueAnnotaiton(Residue residue,
655 ResidueDetailType type)
657 List<ResidueDetail> resDetails = residue.getResidueDetail();
658 for (ResidueDetail resDetail : resDetails)
660 if (resDetail.getProperty().equalsIgnoreCase(type.getCode()))
662 return resDetail.getContent();
669 public boolean isAccessionMatched(String accession)
671 boolean isStrictMatch = true;
672 return isStrictMatch ? curSourceDBRef.equalsIgnoreCase(accession)
673 : curDBRefAccessionIdsString.contains(accession.toLowerCase());
676 private boolean isFoundInSiftsEntry(String accessionId)
678 return accessionId != null
679 && getAllMappingAccession().contains(accessionId);
683 * Pad omitted residue positions in PDB sequence with gaps
687 void padWithGaps(TreeMap<Integer, String> resNumMap,
688 ArrayList<Integer> omitNonObserved)
690 if (resNumMap == null || resNumMap.isEmpty())
694 Integer[] keys = resNumMap.keySet().toArray(new Integer[0]);
696 int firstIndex = keys[0];
697 int lastIndex = keys[keys.length - 1];
698 System.out.println("Min value " + firstIndex);
699 System.out.println("Max value " + lastIndex);
700 for (int x = firstIndex; x <= lastIndex; x++)
702 if (!resNumMap.containsKey(x) && !omitNonObserved.contains(x))
704 resNumMap.put(x, "-");
712 * Target chain to populate mapping of its atom positions.
714 * Two dimension array of residue index versus atom position
715 * @throws IllegalArgumentException
716 * Thrown if chainId or mapping is null
718 void populateAtomPositions(String chainId, HashMap<Integer, int[]> mapping)
719 throws IllegalArgumentException
721 PDBChain chain = pdb.findChain(chainId);
722 if (chain == null || mapping == null)
724 throw new IllegalArgumentException(
725 "Chain id or mapping must not be null.");
727 for (int[] map : mapping.values())
729 if (map[PDB_RES_POS] != UNASSIGNED)
731 map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms);
738 * @param residueIndex
739 * The residue index used for the search
741 * A collection of Atom to search
742 * @return atom position for the given residue index
744 int getAtomIndex(int residueIndex, Collection<Atom> atoms)
748 throw new IllegalArgumentException(
749 "atoms collection must not be null!");
751 for (Atom atom : atoms)
753 if (atom.resNumber == residueIndex)
755 return atom.atomIndex;
762 public Entity getEntityById(String id) throws SiftsException
764 List<Entity> entities = siftsEntry.getEntity();
765 for (Entity entity : entities)
767 if (!entity.getEntityId().equalsIgnoreCase(id))
773 Entity entity = getEntityByMostOptimalMatchedId(id);
778 throw new SiftsException("Entity " + id + " not found");
782 * This method was added because EntityId is NOT always equal to ChainId.
783 * Hence, it provides the logic to greedily detect the "true" Entity for a
784 * given chainId where discrepancies exist.
789 public Entity getEntityByMostOptimalMatchedId(String chainId)
792 .println("--------------> advanced greedy entityId matching block entered..");
793 List<Entity> entities = siftsEntry.getEntity();
794 SiftsEntitySortPojo[] sPojo = new SiftsEntitySortPojo[entities.size()];
796 for (Entity entity : entities)
798 sPojo[count] = new SiftsEntitySortPojo();
799 sPojo[count].entityId = entity.getEntityId();
801 List<Segment> segments = entity.getSegment();
802 for (Segment segment : segments)
804 List<Residue> residues = segment.getListResidue().getResidue();
805 for (Residue residue : residues)
807 List<CrossRefDb> cRefDbs = residue.getCrossRefDb();
808 for (CrossRefDb cRefDb : cRefDbs)
810 if (!cRefDb.getDbSource().equalsIgnoreCase("PDB"))
814 ++sPojo[count].resCount;
815 if (cRefDb.getDbChainId().equalsIgnoreCase(chainId))
817 ++sPojo[count].chainIdFreq;
822 sPojo[count].pid = 100 * (sPojo[count].chainIdFreq / sPojo[count].resCount);
825 Arrays.sort(sPojo, Collections.reverseOrder());
826 System.out.println("highest matched entity : " + sPojo[0].entityId);
827 System.out.println("highest matched pid : " + sPojo[0].pid);
829 if (sPojo[0].entityId != null)
831 for (Entity entity : entities)
833 if (!entity.getEntityId().equalsIgnoreCase(sPojo[0].entityId))
843 public class SiftsEntitySortPojo implements
844 Comparable<SiftsEntitySortPojo>
846 public String entityId;
848 public int chainIdFreq;
855 public int compareTo(SiftsEntitySortPojo o)
857 return this.pid - o.pid;
862 public String[] getEntryDBs()
864 System.out.println("\nListing DB entries...");
865 List<String> availDbs = new ArrayList<String>();
866 List<Db> dbs = siftsEntry.getListDB().getDb();
869 availDbs.add(db.getDbSource());
870 System.out.println(db.getDbSource() + " | " + db.getDbCoordSys());
872 return availDbs.toArray(new String[0]);
876 public StringBuffer getMappingOutput(MappingOutputPojo mp)
877 throws SiftsException
879 String seqRes = mp.getSeqResidue();
880 String seqName = mp.getSeqName();
881 int sStart = mp.getSeqStart();
882 int sEnd = mp.getSeqEnd();
884 String strRes = mp.getStrResidue();
885 String strName = mp.getStrName();
886 int pdbStart = mp.getStrStart();
887 int pdbEnd = mp.getStrEnd();
889 String type = mp.getType();
891 int maxid = (seqName.length() >= strName.length()) ? seqName.length()
893 int len = 72 - maxid - 1;
895 int nochunks = ((seqRes.length()) / len)
896 + ((seqRes.length()) % len > 0 ? 1 : 0);
898 StringBuffer output = new StringBuffer();
899 output.append(NEWLINE);
900 output.append("Sequence ⟷ Structure mapping details").append(NEWLINE);
901 output.append("Method: SIFTS");
902 output.append(NEWLINE).append(NEWLINE);
904 output.append(new Format("%" + maxid + "s").form(seqName));
905 output.append(" : ");
906 output.append(String.valueOf(sStart));
907 output.append(" - ");
908 output.append(String.valueOf(sEnd));
909 output.append(" Maps to ");
910 output.append(NEWLINE);
911 output.append(new Format("%" + maxid + "s").form(structId));
912 output.append(" : ");
913 output.append(String.valueOf(pdbStart));
914 output.append(" - ");
915 output.append(String.valueOf(pdbEnd));
916 output.append(NEWLINE).append(NEWLINE);
918 int matchedSeqCount = 0;
919 for (int j = 0; j < nochunks; j++)
921 // Print the first aligned sequence
922 output.append(new Format("%" + (maxid) + "s").form(seqName)).append(
925 for (int i = 0; i < len; i++)
927 if ((i + (j * len)) < seqRes.length())
929 output.append(seqRes.charAt(i + (j * len)));
933 output.append(NEWLINE);
934 output.append(new Format("%" + (maxid) + "s").form(" ")).append(" ");
936 // Print out the matching chars
937 for (int i = 0; i < len; i++)
941 if ((i + (j * len)) < seqRes.length())
943 if (seqRes.charAt(i + (j * len)) == strRes
944 .charAt(i + (j * len))
945 && !jalview.util.Comparison.isGap(seqRes.charAt(i
951 else if (type.equals("pep"))
953 if (ResidueProperties.getPAM250(seqRes.charAt(i + (j * len)),
954 strRes.charAt(i + (j * len))) > 0)
968 } catch (IndexOutOfBoundsException e)
973 // Now print the second aligned sequence
974 output = output.append(NEWLINE);
975 output = output.append(new Format("%" + (maxid) + "s").form(strName))
977 for (int i = 0; i < len; i++)
979 if ((i + (j * len)) < strRes.length())
981 output.append(strRes.charAt(i + (j * len)));
984 output.append(NEWLINE).append(NEWLINE);
986 float pid = (float) matchedSeqCount / seqRes.length() * 100;
989 throw new SiftsException("Low PID detected for SIFTs mapping...");
991 output.append("Length of alignment = " + seqRes.length()).append(
993 output.append(new Format("Percentage ID = %2.2f").form(pid));
994 output.append(NEWLINE);
999 public int getEntityCount()
1001 return siftsEntry.getEntity().size();
1005 public String getDbAccessionId()
1007 return siftsEntry.getDbAccessionId();
1011 public String getDbCoordSys()
1013 return siftsEntry.getDbCoordSys();
1017 public String getDbEvidence()
1019 return siftsEntry.getDbEvidence();
1023 public String getDbSource()
1025 return siftsEntry.getDbSource();
1029 public String getDbVersion()
1031 return siftsEntry.getDbVersion();