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 0502b2cf authored by Davide Lagoa's avatar Davide Lagoa
Browse files

beta barrels searcher debug

parent 6e8ece7c
......@@ -12,12 +12,15 @@ import pt.uminho.ceb.biosystems.transyt.scraper.transmembraneDomains.betaBarrels
public class TransmembraneDomainsSearcher {
static Map<String, Integer> alphaHelices = new HashMap<>();
static Map<String, Integer> betaBarrels = new HashMap<>();
static Map<String, Integer> alphaHelices;
static Map<String, Integer> betaBarrels;
private static final Logger logger = LoggerFactory.getLogger(TransmembraneDomainsSearcher.class);
public TransmembraneDomainsSearcher(Map<String, AbstractSequence<?>> genome, String email) {
alphaHelices = new HashMap<>();
betaBarrels = new HashMap<>();
search(genome, email);
}
......@@ -27,7 +30,7 @@ public class TransmembraneDomainsSearcher {
* @param email
* @return
*/
private Map<String, Integer> search(Map<String, AbstractSequence<?>> genome, String email) {
private void search(Map<String, AbstractSequence<?>> genome, String email) {
logger.debug("Transmembrane domains search initiated!");
......@@ -57,7 +60,6 @@ public class TransmembraneDomainsSearcher {
logger.trace("StackTrace {}",e);
}
return null;
}
/**
......
......@@ -50,6 +50,7 @@ public class Phobius implements Observer{
ebiAPI.addObserver(this);
results = ebiAPI.getHelicesFromPhobius(genome, new AtomicInteger(0), new AtomicBoolean(), waitingPeriod, new AtomicInteger(0), email);
logger.debug("Transmembrane alpha helices search finished!");
}
catch (InterruptedException e) {
logger.error("An error occurred while searching genome's alpha helices using Phobius! Returning none...");
......
package pt.uminho.ceb.biosystems.transyt.scraper.transmembraneDomains.betaBarrels;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -16,71 +17,108 @@ public class PREDTMBB2 {
private final static String LINK = "http://195.251.108.230/PRED-TMBB2/";
private final static int LIMIT = 5;
private static final Logger logger = LoggerFactory.getLogger(PREDTMBB2.class);
public static Map<String, Integer> searchBetaBarrels(String email, Map<String, AbstractSequence<?>> sequences){
logger.debug("Transmembrane beta barrels search using PRED-TMBB2 initiated!");
String currentUrl;
try {
String query = getCorrectFormatFasta(sequences);
int batchNum = 1;
WebDriver driver = new HtmlUnitDriver();
Map<String, Integer> results = new HashMap<>();
// 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();
Iterator<String> iterator = sequences.keySet().iterator();
boolean submit = true;
while(submit) {
element = driver.findElement(By.xpath("/html/body/form/input[3]")); //uncheck Signal peptide predictions
element.click();
logger.debug("Batch number {} beta-barrels search initiated!", batchNum);
element = driver.findElement(By.xpath("/html/body/form/input[7]")); //email
element.click();
element.sendKeys(email);
Map<String, AbstractSequence<?>> batch = new HashMap<>();
element = driver.findElement(By.xpath("/html/body/form/input[8]")); //run prediction
element.click();
while(iterator.hasNext() && batch.size() < 1000) {
String key = iterator.next(); //PRED-TMBB2 changes all symbols, only accepts "_"
batch.put(key.replace(".", "___"), sequences.get(key)); //Change to the original during the reading process!
}
TimeUnit.SECONDS.sleep(2); // see if necessary
try {
String query = getCorrectFormatFasta(batch);
boolean go = false;
currentUrl = null;
int errorCounter = 0;
WebDriver driver = new HtmlUnitDriver();
while(!go && errorCounter < LIMIT){
// And now use this to visit the website
driver.get(LINK);
try{
// Find the text input element by its name
WebElement element = driver.findElement(By.name("sequence")); //text area
element.sendKeys(query);
currentUrl = driver.getCurrentUrl();
element = driver.findElement(By.xpath("/html/body/form/input[2]")); //check prediction for batch
element.click();
go = true;
}
catch(Exception e){
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);
element = driver.findElement(By.xpath("/html/body/form/input[8]")); //run prediction
element.click();
TimeUnit.SECONDS.sleep(2); // see if necessary
errorCounter ++;
TimeUnit.SECONDS.sleep(10);
boolean go = false;
currentUrl = null;
int errorCounter = 0;
while(!go && errorCounter < LIMIT){
try{
currentUrl = driver.getCurrentUrl();
go = true;
}
catch(Exception e){
errorCounter ++;
TimeUnit.SECONDS.sleep(10);
}
}
if(errorCounter == LIMIT) {
logger.error("An url was not returned by PRED-TMBB2 servers at batch{}! Returning none...", batchNum);
return new HashMap<>();
}
}
catch (Exception e) {
logger.error("An error occurred while searching genome's beta barrels using PRED-TMBB2! Returning none...");
logger.trace("StackTrace {}",e);
return new HashMap<>();
}
}
catch (Exception e) {
logger.error("An error occurred while searching genome's beta barrels using PRED-TMBB2! Returning none...");
logger.trace("StackTrace {}",e);
logger.info("Successfully submitted! Seaching beta barrels at: {}", currentUrl);
results.putAll(ReadPREDTMBB2.readResults(currentUrl));
return new HashMap<>();
if(!iterator.hasNext())
submit = false;
batchNum++;
}
logger.info("Successfully submitted! Seaching beta barrels at: {}", currentUrl);
return ReadPREDTMBB2.readResults(currentUrl);
logger.debug("Transmembrane beta barrels search finished!");
return results;
}
/**
......
......@@ -116,7 +116,7 @@ public class ReadPREDTMBB2 {
}
else{
results.put(entryRes, tmNumberRes);
results.put(entryRes.replace("___", "."), tmNumberRes);
i = -2;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment