Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

Commit af468ddc authored by Davide Lagoa's avatar Davide Lagoa
Browse files

beta barrels email field added

parent 6f4aa5ea
......@@ -13,7 +13,11 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=9
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
......@@ -11,4 +11,4 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=9
org.eclipse.jdt.core.compiler.source=10
897 Desulfococcus multivorans
322 Pseudomonas amygdali pv. tabaci
392416 Lactobacillus crustorum
61015 Staphylococcus succinus
43657 Pseudoalteromonas luteoviolacea
......
897 [Bacteria, Proteobacteria, Deltaproteobacteria, Desulfobacterales, Desulfobacteraceae, Desulfococcus]
322 [Bacteria, Proteobacteria, Gammaproteobacteria, Pseudomonadales, Pseudomonadaceae, Pseudomonas, Pseudomonas amygdali]
392416 [Bacteria, Firmicutes, Bacilli, Lactobacillales, Lactobacillaceae, Lactobacillus]
61015 [Bacteria, Firmicutes, Bacilli, Bacillales, Staphylococcaceae, Staphylococcus]
43657 [Bacteria, Proteobacteria, Gammaproteobacteria, Alteromonadales, Pseudoalteromonadaceae, Pseudoalteromonas]
......
......@@ -28,6 +28,16 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>ebi-repo</id>
<name>ebi-repo</name>
<url>http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
......@@ -98,14 +108,20 @@
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/uk.ac.ebi.chebi.webapps.chebiWS.client/chebiWS-client -->
<dependency>
<groupId>uk.ac.ebi.chebi.webapps.chebiWS.client</groupId>
<artifactId>chebiWS-client</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
package APIs;
import java.util.List;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ebi.chebi.ChebiAPIInterface;
import uk.ac.ebi.chebi.webapps.chebiWS.client.ChebiWebServiceClient;
import uk.ac.ebi.chebi.webapps.chebiWS.model.DataItem;
import uk.ac.ebi.chebi.webapps.chebiWS.model.Entity;
import uk.ac.ebi.chebi.webapps.chebiWS.model.LiteEntity;
import uk.ac.ebi.chebi.webapps.chebiWS.model.LiteEntityList;
import uk.ac.ebi.chebi.webapps.chebiWS.model.SearchCategory;
import uk.ac.ebi.chebi.webapps.chebiWS.model.StarsCategory;
public class ChebiAPI extends ChebiAPIInterface{
static private ChebiWebServiceClient chebiClient = new ChebiWebServiceClient();
public static String getMetacycIDUsingExternalReference(String id) {
String identifier = null;
try {
ChebiWebServiceClient chebiClient = new ChebiWebServiceClient();
LiteEntityList entities = chebiClient.getLiteEntity(id, SearchCategory.MANUAL_XREFS, 1, StarsCategory.THREE_ONLY);
List<LiteEntity> resultList = entities.getListElement();
String chebiID = "";
for (LiteEntity liteEntity : resultList ) {
chebiID = liteEntity.getChebiId();
}
if(chebiID != null && !chebiID.isEmpty()) {
Entity entity = chebiClient.getCompleteEntity(chebiID);
List<DataItem> db = entity.getDatabaseLinks();
for ( DataItem dataItem : db ) { // List all synonyms
if(dataItem.getType().trim().equalsIgnoreCase("MetaCyc accession")) {
identifier = dataItem.getData();
break;
}
}
}
}
catch (Exception e1) {
e1.printStackTrace();
}
return identifier;
}
}
package APIs;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ebi.uniprot.TaxonomyContainer;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ebi.uniprot.UniProtAPI;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.utilities.MySleep;
import uk.ac.ebi.kraken.interfaces.uniprot.NcbiTaxonomyId;
import uk.ac.ebi.kraken.interfaces.uniprot.UniProtEntry;
import uk.ac.ebi.uniprot.dataservice.client.QueryResult;
import uk.ac.ebi.uniprot.dataservice.client.exception.ServiceException;
import uk.ac.ebi.uniprot.dataservice.client.uniprot.UniProtQueryBuilder;
import uk.ac.ebi.uniprot.dataservice.query.Query;
public class UniprotAPIExtension extends UniProtAPI{
final static Logger logger = LoggerFactory.getLogger(UniprotAPIExtension.class);
/**
* @param name
* @param errorCount
* @return
*/
public static String findTaxonmyByOrganismName(String name, int errorCount) {
UniProtAPI.getInstance();
try {
Query query = UniProtQueryBuilder.organismName(name);
QueryResult<UniProtEntry> entries = uniProtService.getEntries(query);
while (entries.hasNext()) {
UniProtEntry entry = entries.next();
if(!entry.getTaxonomy().toString().isEmpty() && entry.getTaxonomy() != null)
return entry.getTaxonomy().toString();
}
}
catch(Exception e) {
if(errorCount<5) {
MySleep.myWait(1000);
errorCount+=1;
logger.debug("Entries From UniProt IDs trial {}",errorCount);
return UniprotAPIExtension.findTaxonmyByOrganismName(name, errorCount);
}
else {
logger.error("Could not retrieve entries list. Returning null. {}",name);
logger.trace("StackTrace {}",e);
return null;
}
}
return null;
}
public static TaxonomyContainer getTaxonomyFromNCBITaxnomyID(int taxID, int errorCount) {
UniProtAPI.getInstance();
TaxonomyContainer result = new TaxonomyContainer();
try {
Query query = UniProtQueryBuilder.taxonID(taxID); //UniprotAPI uses UniProtQueryBuilder.gene() -> wrong
QueryResult<UniProtEntry> entries = uniProtService.getEntries(query);
while(entries.hasNext()) {
UniProtEntry uniProtEntry = entries.next();
List<NcbiTaxonomyId> taxa = uniProtEntry.getNcbiTaxonomyIds();
for(NcbiTaxonomyId taxon : taxa) {
if(taxon.getValue().equalsIgnoreCase(""+taxID)) {
result.setSpeciesName(uniProtEntry.getOrganism().getScientificName().getValue());
result.setTaxonomy(uniProtEntry.getTaxonomy());
return result;
}
}
}
return null;
}
catch(ServiceException e) {
if(errorCount<10) {
MySleep.myWait(1000);
errorCount = errorCount+1;
logger.debug("getTaxonomyFromNCBITaxnomyID trial {}",errorCount);
return getTaxonomyFromNCBITaxnomyID(taxID, errorCount+1);
}
else {
logger.error("getTaxonomyFromNCBITaxnomyID eror, returning null. {}",taxID);
logger.trace("StackTrace {}",e);
return null;
}
}
}
}
......@@ -110,6 +110,8 @@ public class Blast implements Observer{
logger.debug("Reading given target genome FASTA at: {}", queryFilePath); //indicar caminho
System.out.println("temp" + "\t" + currentTempDirectory);
System.out.println(queryFilePath);
ConcurrentHashMap<String, AbstractSequence<?>> sequences= new ConcurrentHashMap<String, AbstractSequence<?>>();
sequences.putAll(FastaReaderHelper.readFastaProteinSequence(new File(queryFilePath)));
......
......@@ -4,57 +4,72 @@ import java.util.HashMap;
import java.util.Map;
import org.biojava.nbio.core.sequence.template.AbstractSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import transmembraneDomains.alpha.SearchAlphaHelices;
import transmembraneDomains.alpha.Phobius;
import transmembraneDomains.betaBarrels.PREDTMBB2;
import transmembraneDomains.betaBarrels.ReadPREDTMBB2;
public class TransmembraneDomainsSearcher {
static Map<String, Integer> alphaHelices = new HashMap<>();
static Map<String, Integer> betaBarrels = new HashMap<>();
Map<String, Integer> alphaHelices = new HashMap<>();
Map<String, Integer> betaBarrels = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(TransmembraneDomainsSearcher.class);
public TransmembraneDomainsSearcher(Map<String, AbstractSequence<?>> genome, String email) {
SearchAlphaHelices.SearchAlphaHelices(genome, email);
// String link = PREDTMBB2.getLink(submap);
//
// System.out.println("AQUIIII -----> " + link);
//
// Map<String, Integer> results = ReadPREDTMBB2.readResults(link, identifiers);
//
// System.out.println("SubResultado ---> " + results);
// // Create two threads:
// Thread thread1 = new Thread() {
// public void run() {
// new Downloader().downloadFromConstructedUrl("http:xxxxx",
// new File("./references/word.txt"),
// new File("./references/words.txt"));
// }
// };
//
// Thread thread2 = new Thread() {
// public void run() {
// new Downloader().downloadFromConstructedUrl("http:xxxxx",
// new File("./references/word1.txt"),
// new File("./references/words1.txt"));
// }
// };
//
//
// // Start the downloads.
// thread1.start();
// thread2.start();
//
// // Wait for them both to finish
// thread1.join();
// thread2.join();
//
// // Continue the execution...
//
search(genome, email);
}
/**
* @param genome
* @param email
* @return
*/
private Map<String, Integer> search(Map<String, AbstractSequence<?>> genome, String email) {
try {
Thread thread1 = new Thread() {
public void run() {
betaBarrels.putAll(PREDTMBB2.searchBetaBarrels(email, genome));
}
};
Thread thread2 = new Thread() {
public void run() {
alphaHelices.putAll((new Phobius(email, genome)).getResults());
}
};
thread1.start();
thread2.start();
thread1.join();
thread2.join();
}
catch (InterruptedException e) {
logger.error("An error occurred while searching genome's transmembrane domains! Returning none...");
logger.trace("StackTrace {}",e);
}
return null;
}
/**
* @return the alphaHelices
*/
public Map<String, Integer> getAlphaHelices() {
return alphaHelices;
}
/**
* @return the betaBarrels
*/
public Map<String, Integer> getBetaBarrels() {
return betaBarrels;
}
}
package transmembraneDomains.alpha;
import java.util.HashMap;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.biojava.nbio.core.sequence.template.AbstractSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ebi.EbiAPI;
/**
* @author Davide
*
*/
public class Phobius implements Observer{
private static final Logger logger = LoggerFactory.getLogger(Phobius.class);
Map<String, Integer> results;
long waitingPeriod = 300000;
/**
* @param genome
* @param email
*/
public Phobius(String email, Map<String, AbstractSequence<?>> genome) {
results = new HashMap<>();
search(genome, email);
}
/**
* @param genome
* @param email
* @return
*/
public Map<String, Integer> search(Map<String, AbstractSequence<?>> genome, String email){
try {
EbiAPI ebiAPI = new EbiAPI();
ebiAPI.addObserver(this);
results = ebiAPI.getHelicesFromPhobius(genome, new AtomicInteger(0), new AtomicBoolean(), waitingPeriod, new AtomicInteger(0), email);
}
catch (InterruptedException e) {
logger.error("An error occurred while searching genome's alpha helices using Phobius! Returning none...");
logger.trace("StackTrace {}",e);
return null;
}
return results;
}
@Override
public void update(Observable arg0, Object arg1) {
// TODO Auto-generated method stub
}
/**
* @return the results
*/
public Map<String, Integer> getResults() {
return results;
}
}
package transmembraneDomains.alpha;
import java.util.Map;
import org.biojava.nbio.core.sequence.template.AbstractSequence;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ebi.EbiAPI;
public class SearchAlphaHelices {
public static Map<String, Integer> SearchAlphaHelices(Map<String, AbstractSequence<?>> genome, String email){
long waitingPeriod = 300000;
Map<String, Integer> results = null;
try {
results = EbiAPI.getHelicesFromPhobius(genome, waitingPeriod, email);
}
catch (InterruptedException e) {
e.printStackTrace();
}
return results;
}
}
package transmembraneDomains.betaBarrels;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -11,88 +9,78 @@ import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PREDTMBB2 {
private final static String LINK = "http://195.251.108.230/PRED-TMBB2/";
private final static int LIMIT = 5;
public static String getLink(Map<String, AbstractSequence<?>> sequences) throws InterruptedException{
private static final Logger logger = LoggerFactory.getLogger(PREDTMBB2.class);
String query = getCorrectFormatFasta(sequences);
//verificar se funciona com esta dependencia!!!!!
WebDriver driver = new HtmlUnitDriver();
public static Map<String, Integer> searchBetaBarrels(String email, Map<String, AbstractSequence<?>> sequences){
// And now use this to visit the website
driver.get(LINK);
// Find the text input element by its name
WebElement element = driver.findElement(By.name("sequence")); //text area
element.sendKeys(query);
element = driver.findElement(By.xpath("/html/body/form/input[2]")); //check prediction for batch
element.click();
String currentUrl;
try {
String query = getCorrectFormatFasta(sequences);
element = driver.findElement(By.xpath("/html/body/form/input[3]")); //uncheck Signal peptide predictions
element.click();
WebDriver driver = new HtmlUnitDriver();
element = driver.findElement(By.xpath("/html/body/form/input[7]")); //run prediction
element.click();
// And now use this to visit the website
driver.get(LINK);
// Find the text input element by its name
WebElement element = driver.findElement(By.name("sequence")); //text area
element.sendKeys(query);
element = driver.findElement(By.xpath("/html/body/form/input[2]")); //check prediction for batch
element.click();
element = driver.findElement(By.xpath("/html/body/form/input[3]")); //uncheck Signal peptide predictions
element.click();
element = driver.findElement(By.xpath("/html/body/form/input[7]")); //email
element.click();
element.sendKeys(email);
// TimeUnit.SECONDS.sleep(); see if necessary
boolean go = false;
String currentUrl = null;
int errorCounter = 0;
while(!go && errorCounter < LIMIT){
element = driver.findElement(By.xpath("/html/body/form/input[8]")); //run prediction
element.click();
try{
TimeUnit.SECONDS.sleep(2); // see if necessary
currentUrl = driver.getCurrentUrl();
go = true;
}
catch(Exception e){
errorCounter ++;
TimeUnit.SECONDS.sleep(10);
}
}
boolean go = false;
currentUrl = null;
int errorCounter = 0;
return currentUrl;
}
@Deprecated
public static String getLink2(String path){
String query = getCorrectFormatFasta2(path);
while(!go && errorCounter < LIMIT){
WebDriver driver = new HtmlUnitDriver();
try{
// And now use this to visit Google
driver.get("http://195.251.108.230/PRED-TMBB2/");
currentUrl = driver.getCurrentUrl();