+
+ /**
+ * Resolve structural model to a reference sequence and register it to
+ * StructureSelectionManager
+ *
+ * @param al
+ * @param querySequence
+ * @param templateSeq
+ * @param structModelHeader
+ * @param structModelData
+ * @return true if model and sequence was added
+ */
+ static boolean processStructModel(AlignmentI al, SequenceI querySequence,
+ SequenceI templateSeq,
+ String[] structModelHeader,
+ String[] structModelData, String baseUri)
+ {
+ String warningMessage = null;
+ boolean added = false;
+ try {
+ String structureModelFile = resolveAbsolutePath(structModelData[2],
+ baseUri);
+ String fastaMappingFile = resolveAbsolutePath(structModelData[3],
+ baseUri);
+ // System.out.println("Model File >> " + structureModelFile);
+ // System.out.println("Fasta File >> " + fastaMappingFile);
+ String modelName = StructureFile.safeName(structureModelFile);
+ PDBEntry phyre2PDBEntry = new PDBEntry(modelName, " ",
+ Type.PDB,
+ structureModelFile);
+ List<DynamicData> phyreDD = generatePhyreDynamicDataList(
+ structModelHeader, structModelData);
+ phyre2PDBEntry.setProperty("DYNAMIC_DATA_PHYRE2", phyreDD);
+ templateSeq.getDatasetSequence().addPDBId(phyre2PDBEntry);
+ if (querySequence != null)
+ {
+ querySequence.getDatasetSequence().addPDBId(phyre2PDBEntry);
+ }
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager();
+ ssm.registerPhyre2Template(structureModelFile, fastaMappingFile);
+ added = true;
+
+ } catch (Exception x)
+ {
+ warningMessage = x.toString();
+ } finally {
+ if (warningMessage !=null)
+ {
+ System.err.println("Warnings whilst processing STRUCTMODEL: "+warningMessage);
+ }
+ }
+ return added;
+ }
+
+ static List<DynamicData> generatePhyreDynamicDataList(
+ String[] headerArray,
+ String[] dataArray)
+ {
+
+ if (headerArray == null || dataArray == null)
+ {
+ throw new IllegalArgumentException(
+ "Header or data arrays must not be null");
+ }
+
+ if (headerArray.length != dataArray.length)
+ {
+ throw new IllegalArgumentException(
+ "Header and data arrays must be of same lenght");
+ }
+ List<DynamicData> dynamicDataList = new ArrayList<DynamicData>();
+ int x = 0;
+ for (String data : dataArray)
+ {
+ // first four column should be hidden;
+ boolean show = (x > 4);
+ dynamicDataList.add(new DynamicData(headerArray[x], data, DataType.S,
+ "PHYRE2", show));
+ x++;
+ }
+ return dynamicDataList;
+ }
+
+ static String resolveAbsolutePath(String relURI, String _baseUri)
+ {
+ if (relURI.indexOf(":/") > -1 || relURI.startsWith("/")
+ || "".equals(_baseUri) || relURI.startsWith(_baseUri))
+ {
+ return relURI;
+ }
+ return _baseUri + relURI;
+ }
+