Commit dc5153e0 authored by Hermann Zellner's avatar Hermann Zellner

Log exceptions

Made InterProXmlToFactConverter usable as a stand-alone tool Application
parent bb04de75
......@@ -17,22 +17,24 @@
package uk.ac.ebi.uniprot.unifire;
import org.uniprot.urml.facts.*;
import uk.ac.ebi.uniprot.urml.core.xml.writers.URMLWriter;
import uk.ac.ebi.uniprot.urml.input.InputType;
import uk.ac.ebi.uniprot.urml.input.parsers.FactSetParser;
import uk.ac.ebi.uniprot.urml.output.xml.IndividualFactWriter;
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.uniprot.urml.facts.*;
/**
* Created by Hermann Zellner on 31/07/2019.
*/
public class InterProXmlToFactConverter {
private static final Logger logger = LoggerFactory.getLogger(InterProXmlToFactConverter.class);
public static void main(String[] argv) throws IOException {
InterProXmlToFactConverter converter = new InterProXmlToFactConverter();
converter.convertToXml(argv[0], argv[1]);
......@@ -45,43 +47,16 @@ public class InterProXmlToFactConverter {
try (URMLWriter<FactSet, Fact> factWriter = new IndividualFactWriter(outputStream)) {
while (factSetIterator.hasNext()) {
FactSet factSet = factSetIterator.next();
List<Fact> facts = new ArrayList<>(factSet.getFact());
PositionalProteinSignature positionalProteinSignature = createPositionalProteinSignatureForJ0U7L2();
facts.add(positionalProteinSignature);
for (Fact fact : facts) {
for (Fact fact : factSet.getFact()) {
factWriter.writeElementWise(fact);
}
factWriter.completeWrite();
}
} catch (Exception e) {
e.printStackTrace();
logger.error("Error while converting InterPro-XML to Fact-XML", e);
}
}
}
private static PositionalProteinSignature createPositionalProteinSignatureForJ0U7L2() {
PositionalProteinSignature positionalProteinSignature = new PositionalProteinSignature();
TemplateProtein protein = new TemplateProtein();
protein.setId("J0U7L2");
positionalProteinSignature.setProtein(protein);
Signature signature = new Signature();
signature.setValue("SRHMM000005-1");
signature.setType(SignatureType.SRHMM);
positionalProteinSignature.setSignature(signature);
positionalProteinSignature.setFrequency(1);
positionalProteinSignature.setPositionStart(1);
positionalProteinSignature.setPositionEnd(208);
SequenceAlignment sequenceAlignment = new SequenceAlignment();
sequenceAlignment.setValue("mlmaavlaapafpafsaget----------------PAAPTKAAAK---PDLVKGEASFTAVCAACHGADGNSAIAANPKLSAQHPEYLVKQLQEFKSG---KRNDPVMKGFAMALSDEDMKNIAYWVTAK-AAKPGFAKDKALVSLGERIYRGGIADRQIAACAGCHSPNGAGIPAQYPRLSGQHADYTATQLVAFRDG");
positionalProteinSignature.setAlignment(sequenceAlignment);
return positionalProteinSignature;
}
}
......@@ -188,12 +188,4 @@
<positionStart>115</positionStart>
<positionEnd>208</positionEnd>
</fact>
<fact xsi:type="PositionalProteinSignature">
<protein>J0U7L2</protein>
<signature type="SRHMM">SRHMM000005-1</signature>
<frequency>1</frequency>
<positionStart>1</positionStart>
<positionEnd>208</positionEnd>
<alignment>mlmaavlaapafpafsaget----------------PAAPTKAAAK---PDLVKGEASFTAVCAACHGADGNSAIAANPKLSAQHPEYLVKQLQEFKSG---KRNDPVMKGFAMALSDEDMKNIAYWVTAK-AAKPGFAKDKALVSLGERIYRGGIADRQIAACAGCHSPNGAGIPAQYPRLSGQHADYTATQLVAFRDG</alignment>
</fact>
</facts>
\ No newline at end of file
......@@ -24,6 +24,8 @@ import java.io.IOException;
import java.io.OutputStream;
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.uniprot.urml.facts.Fact;
import org.uniprot.urml.facts.FactSet;
import org.uniprot.urml.facts.ProteinAnnotation;
......@@ -35,6 +37,7 @@ import org.uniprot.urml.facts.ProteinAnnotation;
*/
public class AnnotationXMLWriter implements FactSetWriter<ProteinAnnotation> {
private static final Logger logger = LoggerFactory.getLogger(AnnotationXMLWriter.class);
private final URMLWriter<FactSet, Fact> urmlFactWriter;
public AnnotationXMLWriter(OutputStream outputStream) {
......@@ -70,7 +73,7 @@ public class AnnotationXMLWriter implements FactSetWriter<ProteinAnnotation> {
} catch (XMLStreamException e) {
throw new IOException(e);
} catch (Exception e) {
e.printStackTrace();
logger.error("Error while closing AnnotationXmlWriter", e);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment