-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44efed5
commit 7de37f7
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
cpath-cli/src/main/java/cpath/analysis/LandingAndLinkout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cpath.analysis; | ||
|
||
import cpath.config.CPathSettings; | ||
import cpath.service.Analysis; | ||
import cpath.service.CPathService; | ||
import cpath.service.CPathUtils; | ||
import org.biopax.paxtools.model.Model; | ||
import org.biopax.paxtools.model.level3.RelationshipXref; | ||
import org.biopax.paxtools.model.level3.UnificationXref; | ||
import org.biopax.paxtools.model.level3.Xref; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.PrintWriter; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
public class LandingAndLinkout implements Analysis<Model> { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(LandingAndLinkout.class); | ||
// public static final String JAVA_OPTION_IDTYPE = "cpath.analysis.linkout.type"; | ||
private static final CPathSettings cpath = CPathSettings.getInstance(); | ||
|
||
@Autowired | ||
CPathService service; | ||
|
||
@Override | ||
public void execute(Model model) { | ||
//export the list of unique UniProt primary accession numbers | ||
LOG.info("creating the list of primary uniprot IDs..."); | ||
Set<String> acs = new TreeSet<>(); | ||
//exclude publication xrefs | ||
Set<Xref> xrefs = new HashSet<>(model.getObjects(UnificationXref.class)); | ||
xrefs.addAll(model.getObjects(RelationshipXref.class)); | ||
long left = xrefs.size(); | ||
for(Xref x : xrefs) { | ||
String id = x.getId(); | ||
if (CPathUtils.startsWithAnyIgnoreCase(x.getDb(),"uniprot") | ||
&& id != null && !acs.contains(id)) | ||
acs.addAll(service.map(id, "UNIPROT")); | ||
if(--left % 10000 == 0) | ||
LOG.info(left + " xrefs to map..."); | ||
} | ||
|
||
PrintWriter writer; | ||
try { | ||
writer = new PrintWriter("uniprot.txt"); | ||
} catch (FileNotFoundException e) { | ||
throw new RuntimeException("", e); | ||
} | ||
writer.println(String.format("#PathwayCommons v%s - primary UniProt accession numbers:", cpath.getVersion())); | ||
for(String ac : acs) | ||
writer.println(ac); | ||
writer.close(); | ||
|
||
LOG.info("generated uniprot.txt"); | ||
} | ||
} |