*/
package jalview.ws.sifts;
-import jalview.analysis.AlignSeq;
-import jalview.analysis.scoremodels.ScoreMatrix;
-import jalview.analysis.scoremodels.ScoreModels;
-import jalview.api.DBRefEntryI;
-import jalview.api.SiftsClientI;
-import jalview.datamodel.DBRefEntry;
-import jalview.datamodel.DBRefSource;
-import jalview.datamodel.SequenceI;
-import jalview.io.StructureFile;
-import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureMapping;
-import jalview.util.Comparison;
-import jalview.util.DBRefUtils;
-import jalview.util.Format;
-import jalview.xml.binding.sifts.Entry;
-import jalview.xml.binding.sifts.Entry.Entity;
-import jalview.xml.binding.sifts.Entry.Entity.Segment;
-import jalview.xml.binding.sifts.Entry.Entity.Segment.ListMapRegion.MapRegion;
-import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue;
-import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.CrossRefDb;
-import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.ResidueDetail;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import MCview.Atom;
import MCview.PDBChain;
+import jalview.analysis.AlignSeq;
+import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.DBRefEntryI;
+import jalview.api.SiftsClientI;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.SequenceI;
+import jalview.io.BackupFiles;
+import jalview.io.StructureFile;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.StructureMapping;
+import jalview.util.Comparison;
+import jalview.util.DBRefUtils;
+import jalview.util.Format;
+import jalview.xml.binding.sifts.Entry;
+import jalview.xml.binding.sifts.Entry.Entity;
+import jalview.xml.binding.sifts.Entry.Entity.Segment;
+import jalview.xml.binding.sifts.Entry.Entity.Segment.ListMapRegion.MapRegion;
+import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue;
+import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.CrossRefDb;
+import jalview.xml.binding.sifts.Entry.Entity.Segment.ListResidue.Residue.ResidueDetail;
public class SiftsClient implements SiftsClientI
{
private enum CoordinateSys
{
UNIPROT("UniProt"), PDB("PDBresnum"), PDBe("PDBe");
+
private String name;
private CoordinateSys(String name)
{
NAME_SEC_STRUCTURE("nameSecondaryStructure"),
CODE_SEC_STRUCTURE("codeSecondaryStructure"), ANNOTATION("Annotation");
+
private String code;
private ResidueDetailType(String code)
SiftsSettings.getCacheThresholdInDays()))
{
File oldSiftsFile = new File(siftsFileName + "_old");
- siftsFile.renameTo(oldSiftsFile);
+ BackupFiles.moveFileToFile(siftsFile, oldSiftsFile);
try
{
siftsFile = downloadSiftsFile(pdbId.toLowerCase());
} catch (IOException e)
{
e.printStackTrace();
- oldSiftsFile.renameTo(siftsFile);
+ BackupFiles.moveFileToFile(oldSiftsFile, siftsFile);
return new File(siftsFileName);
}
}
SequenceI seq, java.io.PrintStream os) throws SiftsException
{
List<Integer> omitNonObserved = new ArrayList<>();
- int nonObservedShiftIndex = 0,pdbeNonObserved=0;
+ int nonObservedShiftIndex = 0, pdbeNonObserved = 0;
// System.out.println("Generating mappings for : " + entityId);
Entity entity = null;
entity = getEntityById(entityId);
TreeMap<Integer, String> resNumMap = new TreeMap<Integer, String>();
List<Segment> segments = entity.getSegment();
SegmentHelperPojo shp = new SegmentHelperPojo(seq, mapping, resNumMap,
- omitNonObserved, nonObservedShiftIndex,pdbeNonObserved);
+ omitNonObserved, nonObservedShiftIndex, pdbeNonObserved);
processSegments(segments, shp);
try
{
{
throw new SiftsException("SIFTS mapping failed");
}
- // also construct a mapping object between the seq-coord sys and the PDB seq's coord sys
+ // also construct a mapping object between the seq-coord sys and the PDB
+ // seq's coord sys
Integer[] keys = mapping.keySet().toArray(new Integer[0]);
Arrays.sort(keys);
seqStart = keys[0];
seqEnd = keys[keys.length - 1];
- List<int[]> from=new ArrayList<>(),to=new ArrayList<>();
- int[]_cfrom=null,_cto=null;
+ List<int[]> from = new ArrayList<>(), to = new ArrayList<>();
+ int[] _cfrom = null, _cto = null;
String matchedSeq = originalSeq;
- if (seqStart != UNASSIGNED) // fixme! seqStart can map to -1 for a pdb sequence that starts <-1
+ if (seqStart != UNASSIGNED) // fixme! seqStart can map to -1 for a pdb
+ // sequence that starts <-1
{
- for (int seqps:keys)
+ for (int seqps : keys)
{
int pdbpos = mapping.get(seqps)[PDBE_POS];
if (pdbpos == UNASSIGNED)
// not correct - pdbpos might be -1, but leave it for now
continue;
}
- if (_cfrom==null || seqps!=_cfrom[1]+1)
+ if (_cfrom == null || seqps != _cfrom[1] + 1)
{
- _cfrom = new int[] { seqps,seqps};
+ _cfrom = new int[] { seqps, seqps };
from.add(_cfrom);
_cto = null; // discontinuity
- } else {
- _cfrom[1]= seqps;
}
- if (_cto==null || pdbpos!=1+_cto[1])
+ else
+ {
+ _cfrom[1] = seqps;
+ }
+ if (_cto == null || pdbpos != 1 + _cto[1])
{
- _cto = new int[] { pdbpos,pdbpos};
+ _cto = new int[] { pdbpos, pdbpos };
to.add(_cto);
- } else {
+ }
+ else
+ {
_cto[1] = pdbpos;
}
}
;
seqFromPdbMapping = new jalview.datamodel.Mapping(null, _cto, _cfrom,
- 1,
- 1);
+ 1, 1);
pdbStart = mapping.get(seqStart)[PDB_RES_POS];
pdbEnd = mapping.get(seqEnd)[PDB_RES_POS];
int orignalSeqStart = seq.getStart();
}
// if (currSeqIndex >= seq.getStart() && currSeqIndex <= seqlength) //
// true
- // numbering
- // is
- // not
- // up
- // to
- // seq.getEnd()
+ // numbering
+ // is
+ // not
+ // up
+ // to
+ // seq.getEnd()
{
int resNum = (pdbRefDb == null)
{
return pdbeNonObserved;
}
+
public SequenceI getSeq()
{
return seq;