.getMappingFromS1(false);
if (targetChainId != null && !targetChainId.trim().isEmpty())
{
- StructureMapping mapping;
+ StructureMapping siftsMapping;
try
{
- mapping = getStructureMapping(seq, pdbFile, targetChainId, pdb,
- maxChain, sqmpping, maxAlignseq);
- seqToStrucMapping.add(mapping);
+ siftsMapping = getStructureMapping(seq, pdbFile, targetChainId,
+ pdb, maxChain, sqmpping, maxAlignseq);
+ seqToStrucMapping.add(siftsMapping);
+ maxChain.makeExactMapping(maxAlignseq, seq);
+ maxChain.transferRESNUMFeatures(seq, null);
+ maxChain.transferResidueAnnotation(siftsMapping, sqmpping);
} catch (SiftsException e)
{
- // e.printStackTrace();
// fall back to NW alignment
System.err.println(e.getMessage());
- seqToStrucMapping.add(getNWMappings(seq, pdbFile,
- targetChainId,
- maxChain, pdb, maxAlignseq));
+ StructureMapping nwMapping = getNWMappings(seq, pdbFile,
+ targetChainId, maxChain, pdb, maxAlignseq);
+ seqToStrucMapping.add(nwMapping);
}
}
else
{
- try
+ ArrayList<StructureMapping> foundSiftsMappings = new ArrayList<StructureMapping>();
+ for (PDBChain chain : pdb.getChains())
{
- ArrayList<StructureMapping> tempMapping = new ArrayList<StructureMapping>();
- for (PDBChain chain : pdb.getChains())
+ try
{
- StructureMapping mapping = getStructureMapping(seq, pdbFile,
+ StructureMapping siftsMapping = getStructureMapping(seq,
+ pdbFile,
chain.id, pdb, chain, sqmpping, maxAlignseq);
- tempMapping.add(mapping);
+ foundSiftsMappings.add(siftsMapping);
+ } catch (SiftsException e)
+ {
+ System.err.println(e.getMessage());
}
- seqToStrucMapping.addAll(tempMapping);
- } catch (SiftsException e)
+ }
+ if (!foundSiftsMappings.isEmpty())
{
- // e.printStackTrace();
- // fall back to NW alignment
- System.err.println(e.getMessage());
- seqToStrucMapping.add(getNWMappings(seq, pdbFile, maxChainId,
- maxChain, pdb, maxAlignseq));
+ seqToStrucMapping.addAll(foundSiftsMappings);
+ maxChain.makeExactMapping(maxAlignseq, seq);
+ maxChain.transferRESNUMFeatures(seq, null);
+ maxChain.transferResidueAnnotation(foundSiftsMappings.get(0),
+ sqmpping);
+ }
+ else
+ {
+ StructureMapping nwMapping = getNWMappings(seq, pdbFile,
+ maxChainId, maxChain, pdb, maxAlignseq);
+ seqToStrucMapping.add(nwMapping);
}
}
}
private static final int PDB_ATOM_POS = 1;
- private static final String NOT_FOUND = "Not_Found";
-
private static final String NOT_OBSERVED = "Not_Observed";
- private static final String SIFTS_FTP_BASE_URL = "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
+ private static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
private final static String NEWLINE = System.lineSeparator();
*/
public static File getSiftsFile(String pdbId) throws SiftsException
{
- File siftsFile = new File(SiftsSettings.getSiftDownloadDirectory()
- + pdbId.toLowerCase() + ".xml.gz");
+ String siftsFileName = SiftsSettings.getSiftDownloadDirectory()
+ + pdbId.toLowerCase() + ".xml.gz";
+ File siftsFile = new File(siftsFileName);
if (siftsFile.exists())
{
// The line below is required for unit testing... don't comment it out!!!
if (isFileOlderThanThreshold(siftsFile,
SiftsSettings.getCacheThresholdInDays()))
{
- // System.out.println("Downloaded file is out of date, hence re-downloading...");
- siftsFile = downloadSiftsFile(pdbId.toLowerCase());
+ File oldSiftsFile = new File(siftsFileName + "_old");
+ siftsFile.renameTo(oldSiftsFile);
+ try
+ {
+ siftsFile = downloadSiftsFile(pdbId.toLowerCase());
+ oldSiftsFile.delete();
+ return siftsFile;
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ oldSiftsFile.renameTo(siftsFile);
+ return new File(siftsFileName);
+ }
}
- return siftsFile;
}
- siftsFile = downloadSiftsFile(pdbId.toLowerCase());
+ try
+ {
+ siftsFile = downloadSiftsFile(pdbId.toLowerCase());
+ } catch (IOException e)
+ {
+ throw new SiftsException(e.getMessage());
+ }
return siftsFile;
}
* @param pdbId
* @return downloaded SIFTs XML file
* @throws SiftsException
+ * @throws IOException
*/
- public static File downloadSiftsFile(String pdbId) throws SiftsException
+ public static File downloadSiftsFile(String pdbId) throws SiftsException,
+ IOException
{
if (pdbId.contains(".cif"))
{
{
siftsDownloadDir.mkdirs();
}
- try
- {
// System.out.println(">> Download ftp url : " + siftsFileFTPURL);
URL url = new URL(siftsFileFTPURL);
URLConnection conn = url.openConnection();
outputStream.close();
inputStream.close();
// System.out.println(">>> File downloaded : " + downloadedSiftsFile);
- } catch (IOException ex)
- {
- throw new SiftsException(ex.getMessage());
- }
return new File(downloadedSiftsFile);
}
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
// Assert that file isn't yet downloaded - if already downloaded, assert it
// is deleted
Assert.assertTrue(SiftsClient.deleteSiftsFileByPDBId(testPDBId));
- File siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
- FileAssert.assertFile(siftsFile);
- SiftsClient.downloadSiftsFile(testPDBId);
+ File siftsFile;
+ try
+ {
+ siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
+ FileAssert.assertFile(siftsFile);
+ SiftsClient.downloadSiftsFile(testPDBId);
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
}
@Test(groups = { "Functional" })