Skip to content

Commit

Permalink
Merge pull request medbioinf#206 from julianu/main
Browse files Browse the repository at this point in the history
enabling mzid1.2 import
  • Loading branch information
julianu authored Jul 5, 2024
2 parents 79b00bf + ca3cae5 commit a17b10c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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

0 comments on commit a17b10c

Please sign in to comment.