use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mmtf-spark by sbl-sdsc.
the class MmtfImporter method getFromPdbUrl.
/**
* Reads a PDB file from a URL.
*
* @param uniProtId
* @return
* @throws IOException
*/
private static AdapterToStructureData getFromPdbUrl(String url, String structureId) throws IOException {
URL u = new URL(url);
InputStream is = null;
try {
is = u.openStream();
} catch (IOException e) {
return null;
}
AdapterToStructureData structure = toStructureDataInterface(is, structureId);
is.close();
return structure;
}
use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mmtf-spark by sbl-sdsc.
the class MmtfImporter method getFromPdbFile.
/**
* Reads a PDB file from a file system.
*
* @param
* @return
* @throws IOException
*/
private static AdapterToStructureData getFromPdbFile(File file, String structureId) throws IOException {
AdapterToStructureData structure = null;
InputStream is = null;
String path = file.toString();
if (path.endsWith(".pdb.gz") || path.endsWith(".ent.gz")) {
is = new GZIPInputStream(new FileInputStream(file));
structure = toStructureDataInterface(is, structureId);
} else if (path.endsWith(".pdb") || path.endsWith(".ent")) {
is = new FileInputStream(file);
structure = toStructureDataInterface(is, structureId);
} else {
return null;
}
is.close();
return structure;
}
use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.
the class MergeMmtf method MergeStructures.
public static StructureDataInterface MergeStructures(String structureId, StructureDataInterface... structures) {
for (StructureDataInterface s : structures) {
if (s.getNumModels() != 1) {
throw new IllegalArgumentException("ERROR: Cannot merge structures with more than one model");
}
}
AdapterToStructureData complex = new AdapterToStructureData();
initStructure(structureId, structures, complex);
addEntityInfo(structures, complex);
for (StructureDataInterface structure : structures) {
addStructure(structure, complex);
}
complex.finalizeStructure();
return complex;
}
use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.
the class Molmporter method readFile.
public AdapterToStructureData readFile(String fileName) throws IOException {
InputStream is = new FileInputStream(fileName);
AdapterToStructureData structure = read(is, fileName);
is.close();
return structure;
}
use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.
the class Molmporter method readUrl.
public AdapterToStructureData readUrl(String url) throws IOException {
URL u = new URL(url);
InputStream is = null;
try {
is = u.openStream();
} catch (IOException e) {
return null;
}
AdapterToStructureData structure = read(is, url);
return structure;
}
Aggregations