Skip to content

Commit

Permalink
Fix for a NPE bug related to PathwayCommons/cpath2#321 case (when act…
Browse files Browse the repository at this point in the history
…ual large blacklist of ubiquitous mol. was used)
  • Loading branch information
IgorRodchenkov committed Jul 4, 2024
1 parent 3d3ee51 commit aaceda2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions sbgn-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@
<artifactId>chilay-sbgn</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.biopax.paxtools</groupId>
<artifactId>pattern</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ public Sbgn createSBGN(Model model) {
//a Control without controlled process but with controller and is controlledOf
if(control.getControlled().isEmpty()) {
Glyph g = createControlStructure(control);
processControllers(control.getControlledOf(), g);
if(g != null) {
processControllers(control.getControlledOf(), g);
}
}//else - do nothing - as it's converted anyway when the controlled interactions are processed
}

Expand Down Expand Up @@ -1280,8 +1282,8 @@ private void addPorts(Glyph g) {
* Creates an arc from the source to the target, and sets its class to the specified clazz.
* Puts the new arc in the sullied arcMap.
*
* @param source source of the arc -- either Glyph or Port
* @param target target of the arc -- either Glyph or Port
* @param source - source of the arc -- either Glyph or Port
* @param target - target of the arc -- either Glyph or Port
* @param clazz class of the arc
*/
private void createArc(Object source, Object target, String clazz, Stoichiometry stoic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.biopax.paxtools.model.BioPAXLevel;
import org.biopax.paxtools.model.Model;
import org.biopax.paxtools.model.level3.*;
import org.biopax.paxtools.pattern.util.Blacklist;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.sbgn.GlyphClazz;
import org.sbgn.SbgnUtil;
Expand All @@ -20,6 +22,8 @@
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -383,4 +387,24 @@ private Collection<Glyph> filterGlyphsByClazz(Collection<Glyph> collection, Stri
private Collection<Arc> filterArcsByClazz(Collection<Arc> collection, String clazz) {
return collection.stream().filter(g -> g.getClazz().equals(clazz)).collect(Collectors.toUnmodifiableSet());
}

@Disabled
@Test
public void convertPc14NearestNeighborhoodOfANK1_PTEN() throws Exception
{
Model level3 = handler.convertFromOWL(Files.newInputStream(Paths.get("/home/igor/Downloads/cpath2-issue-321-pc14-nhood-ank1-pten-data.owl")));
String out = "target/cpath2-321.sbgn";

UbiqueDetector bl = new ListUbiqueDetector(new Blacklist("/home/igor/Workspace/pc-stack/work/downloads/blacklist.txt").getListed());
L3ToSBGNPDConverter conv = new L3ToSBGNPDConverter(bl,null, false);
conv.writeSBGN(level3, out);

File outFile = new File(out);
SbgnUtil.isValid(outFile); //ignore CName warning
// Now read the SBGN model back
Sbgn result = (Sbgn) unmarshaller.unmarshal (outFile);
// Assert that the sbgn result contains glyphs
List<Glyph> glyphList = result.getMap().getGlyph();
assertFalse(glyphList.isEmpty());
}
}

0 comments on commit aaceda2

Please sign in to comment.