Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabling mzid1.2 import #206

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>de.mpc.pia</groupId>
<artifactId>pia</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<name>PIA - Protein Inference Algorithms</name>
<url>https://github.com/mpc-bioinformatics/pia</url>

Expand Down
26 changes: 24 additions & 2 deletions src/main/java/de/mpc/pia/intermediate/compiler/PIACompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
Expand All @@ -21,6 +22,7 @@
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLOutputFactory;
Expand Down Expand Up @@ -135,13 +137,13 @@ public abstract class PIACompiler {
private static String nsjPiaXML = "http://www.medizinisches-proteom-center.de/PIA/piaintermediate";

/** prefixdeclaration for jPiaXML */
private static String prefixjPiaXML = "ns3";
private static String prefixjPiaXML = "pia";

/** namespace declaration for mzIdentML */
private static String nsMzIdentML = "http://psidev.info/psi/pi/mzIdentML/1.1";

/** prefix declaration for mzIdentML */
private static String prefixMzIdentML = "ns2";
private static String prefixMzIdentML = "mzid";

/** encoding specification */
private static String encoding = "UTF-8";
Expand Down Expand Up @@ -933,6 +935,26 @@ public final void writeOutXML(OutputStream outputStream) {
XMLOutputFactory xmlof = XMLOutputFactory.newInstance();
XMLStreamWriter xmlOut = new IndentingXMLStreamWriter(xmlof.createXMLStreamWriter(out));

// take care of the namespace in the PIA XML files -> basically set them fixed to PIA and mzid 1.1
xmlOut.setNamespaceContext(new NamespaceContext() {
public Iterator<String> getPrefixes(String namespaceURI) {
return null;
}

public String getPrefix(String namespaceURI) {
if (namespaceURI.equals(nsjPiaXML)) {
return prefixjPiaXML;
} else if (namespaceURI.contains("mzIdentML")) {
return prefixMzIdentML;
}
return "";
}

public String getNamespaceURI(String prefix) {
return "";
}
});

// xml header
xmlOut.writeStartDocument(encoding, "1.0");

Expand Down
Loading