*
* @param sequenceArray
* - one or more sequences to be mapped to pdbFile
- * @param targetChains
+ * @param targetChainIds
* - optional chain specification for mapping each sequence to pdb
* (may be nill, individual elements may be nill)
* @param pdbFile
* @return null or the structure data parsed as a pdb file
*/
synchronized public PDBfile setMapping(boolean forStructureView,
- SequenceI[] sequenceArray, String[] targetChains, String pdbFile,
+ SequenceI[] sequenceArray, String[] targetChainIds,
+ String pdbFile,
String protocol)
{
/*
{
pdb = new PDBfile(addTempFacAnnot, parseSecStr, secStructServices,
pdbFile, protocol);
- if (isMapUsingSIFTs)
- {
- siftsClient = new SiftsClient(pdb);
- }
+
if (pdb.id != null && pdb.id.trim().length() > 0
&& AppletFormatAdapter.FILE.equals(protocol))
{
registerPDBFile(pdb.id.trim(), pdbFile);
}
- } catch (SiftsException e)
- {
- e.printStackTrace();
} catch (Exception ex)
{
ex.printStackTrace();
return null;
}
- String targetChain;
+ try
+ {
+ if (isMapUsingSIFTs)
+ {
+ siftsClient = new SiftsClient(pdb);
+ }
+ } catch (SiftsException e)
+ {
+ isMapUsingSIFTs = false;
+ e.printStackTrace();
+ }
+
+ String targetChainId;
for (int s = 0; s < sequenceArray.length; s++)
{
boolean infChain = true;
final SequenceI seq = sequenceArray[s];
- if (targetChains != null && targetChains[s] != null)
+ if (targetChainIds != null && targetChainIds[s] != null)
{
infChain = false;
- targetChain = targetChains[s];
+ targetChainId = targetChainIds[s];
}
else if (seq.getName().indexOf("|") > -1)
{
- targetChain = seq.getName().substring(
+ targetChainId = seq.getName().substring(
seq.getName().lastIndexOf("|") + 1);
- if (targetChain.length() > 1)
+ if (targetChainId.length() > 1)
{
- if (targetChain.trim().length() == 0)
+ if (targetChainId.trim().length() == 0)
{
- targetChain = " ";
+ targetChainId = " ";
}
else
{
// not a valid chain identifier
- targetChain = "";
+ targetChainId = "";
}
}
}
else
{
- targetChain = "";
+ targetChainId = "";
}
/*
boolean first = true;
for (PDBChain chain : pdb.chains)
{
- if (targetChain.length() > 0 && !targetChain.equals(chain.id)
+ if (targetChainId.length() > 0 && !targetChainId.equals(chain.id)
&& !infChain)
{
continue; // don't try to map chains don't match.
// as.traceAlignment();
if (first || as.maxscore > max
- || (as.maxscore == max && chain.id.equals(targetChain)))
+ || (as.maxscore == max && chain.id.equals(targetChainId)))
{
first = false;
maxChain = chain;
{
try
{
+ jalview.datamodel.Mapping sqmpping = maxAlignseq
+ .getMappingFromS1(false);
seqToStrucMapping = new ArrayList<StructureMapping>();
- if (targetChain != null && !targetChain.trim().isEmpty())
+ if (targetChainId != null && !targetChainId.trim().isEmpty())
{
- maxChainId = targetChain;
StructureMapping curChainMapping = siftsClient
- .getSiftsStructureMapping(seq, pdbFile, targetChain);
+ .getSiftsStructureMapping(seq, pdbFile, targetChainId);
seqToStrucMapping.add(curChainMapping);
+ maxChainId = targetChainId;
+ PDBChain chain = pdb.findChain(targetChainId);
+ if (chain != null)
+ {
+ chain.transferResidueAnnotation(curChainMapping, sqmpping);
+ }
}
else
{
for (PDBChain chain : pdb.chains)
{
- maxChainId = chain.id;
StructureMapping curChainMapping = siftsClient
.getSiftsStructureMapping(seq, pdbFile, chain.id);
seqToStrucMapping.add(curChainMapping);
+ maxChainId = chain.id;
+ chain.transferResidueAnnotation(curChainMapping, sqmpping);
}
}
} catch (SiftsException e)
{
+ e.printStackTrace();
System.err
.println(">>>>>>> SIFTs mapping could not be obtained... Now mapping with NW alignment");
seqToStrucMapping = getNWMappings(seq, pdbFile, maxChainId,
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 jalview.xml.binding.sifts.Entry.ListDB.Db;
import java.io.File;
return name;
}
};
-
+
+ public enum ResidueDetailType
+ {
+ NAME_SEC_STRUCTURE("nameSecondaryStructure"), CODE_SEC_STRUCTURE(
+ "codeSecondaryStructure"), ANNOTATION("Annotation");
+ private String code;
+
+ private ResidueDetailType(String code)
+ {
+ this.code = code;
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+ };
+
/**
* Fetch SIFTs file for the given PDB Id and construct an instance of
* SiftsClient
} catch (JAXBException e)
{
e.printStackTrace();
+ throw new SiftsException(e.getMessage());
} catch (FileNotFoundException e)
{
e.printStackTrace();
+ throw new SiftsException(e.getMessage());
} catch (XMLStreamException e)
{
e.printStackTrace();
+ throw new SiftsException(e.getMessage());
} catch (FactoryConfigurationError e)
{
e.printStackTrace();
+ throw new SiftsException(e.getMessage());
} catch (IOException e)
{
e.printStackTrace();
+ throw new SiftsException(e.getMessage());
}
- throw new SiftsException("Error parsing siftFile");
}
/**
*
* @param pdbId
* @return SIFTs XML file
+ * @throws SiftsException
*/
- public static File getSiftsFile(String pdbId)
+ public static File getSiftsFile(String pdbId) throws SiftsException
{
File siftsFile = new File(SIFTS_DOWNLOAD_DIR + pdbId.toLowerCase()
+ ".xml.gz");
*
* @param pdbId
* @return downloaded SIFTs XML file
+ * @throws SiftsException
*/
- public static File downloadSiftsFile(String pdbId)
+ public static File downloadSiftsFile(String pdbId) throws SiftsException
{
String siftFile = pdbId + ".xml.gz";
String siftsFileFTPURL = SIFTS_FTP_BASE_URL + siftFile;
System.out.println(">>> File downloaded : " + downloadedSiftsFile);
} catch (IOException ex)
{
- ex.printStackTrace();
+ throw new SiftsException(ex.getMessage());
}
return new File(downloadedSiftsFile);
}
java.io.PrintStream os)
throws SiftsException
{
-
System.out.println("Generating mappings for : " + entityId);
Entity entity = null;
entity = getEntityById(entityId);
residuePos[PDB_RES_POS] = UNASSIGNED;
residuePos[PDB_ATOM_POS] = UNASSIGNED;
}
-
TreeMap<Integer, String> resNumMap = new TreeMap<Integer, String>();
List<Segment> segments = entity.getSegment();
for (Segment segment : segments)
}
try
{
- mapping[currSeqIndex][PDB_RES_POS] = Integer.valueOf(resNum);
+ mapping[currSeqIndex][PDB_RES_POS] = Integer
+ .valueOf(resNum);
} catch (ArrayIndexOutOfBoundsException e)
{
// do nothing..
return mapping;
}
+ private boolean isResidueObserved(Residue residue)
+ {
+ String annotation = getResidueAnnotaiton(residue,
+ ResidueDetailType.ANNOTATION);
+ if (annotation == null)
+ {
+ return true;
+ }
+ if (!annotation.equalsIgnoreCase("Not_Found")
+ && annotation.equalsIgnoreCase("Not_Observed"))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private String getResidueAnnotaiton(Residue residue,
+ ResidueDetailType type)
+ {
+ List<ResidueDetail> resDetails = residue.getResidueDetail();
+ for (ResidueDetail resDetail : resDetails)
+ {
+ if (resDetail.getProperty().equalsIgnoreCase(type.getCode()))
+ {
+ return resDetail.getContent();
+ }
+ }
+ return "Not_Found";
+ }
+
private boolean hasAccessionId(String accession)
{
boolean isStrictMatch = true;
}
@Test(groups = { "Functional" })
- public void getSIFTsFileTest()
+ public void getSIFTsFileTest() throws SiftsException
{
Assert.assertTrue(SiftsClient.deleteSiftsFileByPDBId(testPDBId));
SiftsClient.getSiftsFile(testPDBId);
}
@Test(groups = { "Functional" })
- public void downloadSiftsFileTest()
+ public void downloadSiftsFileTest() throws SiftsException
{
// Assert that file isn't yet downloaded - if already downloaded, assert it
// is deleted