use of org.intermine.xml.full.ItemFactory in project intermine by intermine.
the class DataSourceUpdater method execute.
/**
* For each data set in the objectstore, retreive it's details from UniProt data file
* @throws BuildException if an error occurs
*/
@Override
public void execute() {
// Needed so that STAX can find it's implementation classes
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
if (osAlias == null) {
throw new BuildException("osAlias attribute is not set");
}
if (outputFile == null) {
throw new BuildException("outputFile attribute is not set");
}
if (dataSourceFile == null) {
throw new BuildException("dataSourceFile attribute is not set");
}
LOG.info("Starting DataSourceUpdater");
Writer writer = null;
try {
writer = new FileWriter(outputFile);
ObjectStore os = ObjectStoreFactory.getObjectStore(osAlias);
// get the data sources already in the database
dataSourceNames = getDataSources(os);
// parse the uniprot data source file
Map<String, DataSourceHolder> allDataSources = parseDataFile(new FileReader(dataSourceFile));
ItemFactory itemFactory = new ItemFactory(os.getModel(), "-1_");
writer.write(FullRenderer.getHeader() + "\n");
// write the relevant data sources to file
for (DataSourceHolder holder : allDataSources.values()) {
Item datasource = itemFactory.makeItemForClass("DataSource");
datasource.setAttribute("name", holder.name);
if (holder.descr != null) {
datasource.setAttribute("description", holder.descr);
}
if (holder.url != null) {
datasource.setAttribute("url", holder.url);
}
if (holder.pubMedId != null) {
Item publication = itemFactory.makeItemForClass("Publication");
publication.setAttribute("pubMedId", holder.pubMedId);
writer.write(FullRenderer.render(publication));
datasource.addToCollection("publications", publication);
}
writer.write(FullRenderer.render(datasource));
}
writer.write(FullRenderer.getFooter() + "\n");
} catch (Exception e) {
throw new BuildException("exception while retrieving data sets", e);
} finally {
Thread.currentThread().setContextClassLoader(cl);
if (writer != null) {
try {
writer.close();
} catch (Exception e) {
// ignore
}
}
}
}
use of org.intermine.xml.full.ItemFactory in project intermine by intermine.
the class GoConverterTest method testCreateWithObjects.
public void testCreateWithObjects() throws Exception {
ItemFactory tgtItemFactory = new ItemFactory(Model.getInstanceByName("genomic"));
Item organism = tgtItemFactory.makeItem("3_1", "Organism", "");
organism.setAttribute("taxonId", "7227");
Set<String> expected = new HashSet<String>();
expected.add("4_1");
expected.add("4_2");
converter.initialiseMapsForFile();
assertEquals(expected, new HashSet<String>(converter.createWithObjects("FLYBASE:Grip84; FB:FBgn0026430, FLYBASE:l(1)dd4; FB:FBgn0001612", organism)));
}
use of org.intermine.xml.full.ItemFactory in project intermine by intermine.
the class CreateChromosomeLocationsProcessTest method setUp.
public void setUp() throws Exception {
osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.bio-test");
osw.getObjectStore().flushObjectById();
model = Model.getInstanceByName("genomic");
itemFactory = new ItemFactory(model);
}
use of org.intermine.xml.full.ItemFactory in project intermine by intermine.
the class MakeSpanningLocationsProcessTest method setUp.
public void setUp() throws Exception {
osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.bio-test");
osw.getObjectStore().flushObjectById();
model = Model.getInstanceByName("genomic");
itemFactory = new ItemFactory(model);
}
use of org.intermine.xml.full.ItemFactory in project intermine by intermine.
the class GFF3RecordHandlerTest method setUp.
public void setUp() throws Exception {
tgtModel = Model.getInstanceByName("genomic");
itemFactory = new ItemFactory(tgtModel);
}
Aggregations