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

logger, blast and TRIAGE neo4j database

parent c693031a
......@@ -8,11 +8,16 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<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=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
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
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.source=1.8
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
......@@ -16,13 +16,14 @@
<build>
<plugins>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> <configuration> <source>9</source> <target>9</target>
</configuration> </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.9</source>
<target>1.9</target>
<release>10</release>
</configuration>
</plugin>
</plugins>
......
......@@ -6,7 +6,9 @@ import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
......@@ -26,104 +28,157 @@ import org.biojava.nbio.core.sequence.template.AbstractSequence;
import pt.uminho.ceb.biosystems.merlin.bioapis.externalAPI.ncbi.CreateGenomeFile;
import pt.uminho.ceb.biosystems.merlin.local.alignments.core.RunSimilaritySearch;
import pt.uminho.ceb.biosystems.merlin.local.alignments.core.ModelMerge.BlastAlignment;
import pt.uminho.ceb.biosystems.merlin.utilities.Enumerators.AlignmentScoreType;
import pt.uminho.ceb.biosystems.merlin.utilities.Enumerators.Method;
import pt.uminho.ceb.biosystems.merlin.utilities.containers.capsules.AlignmentCapsule;
import tcdb.tcdbTransportTypesRetriever.TcdbExplorer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Davide
*
*/
public class Blast implements Observer{
private static final Logger logger = LoggerFactory.getLogger(Blast.class);
ConcurrentLinkedQueue<AlignmentCapsule> results;
public Blast() {
try {
performBlast();
logger.info("Blast process initializing...");
results = performBlast();
logger.info("Blast process finished!");
}
catch (Exception e) {
e.printStackTrace();
}
}
private void performBlast() throws Exception {
/**
* Method were all configurations to perform BLAST are set.
*
* @return
* @throws Exception
*/
private ConcurrentLinkedQueue<AlignmentCapsule> performBlast() throws Exception {
//BLAST
System.out.println("INIT BLAST!!");
String filePath = "C:/Users/Davide/Documents/reactionsBuilderTriage/temp/";
String tcdbFastaFile = filePath.concat("tcdbSEQs.txt");
logger.info("Downloading FASTA file from TCDB at: "); //incluir endereço e excepçoes caso nao consiga aceder à net
Map<String, AbstractSequence<?>> tcdbGenes = getTcdbInMapFormat();
System.out.println("BIOJAVA TCDB!!");
logger.debug("Saving TCDB fasta in local folder: "); //indicar o caminho
CreateGenomeFile.buildFastaFile(tcdbFastaFile, tcdbGenes);
System.out.println("BIOJAVA RENATO!!");
logger.debug("Reading given target genome FASTA at: "); //indicar caminho
ConcurrentHashMap<String, AbstractSequence<?>> sequences= new ConcurrentHashMap<String, AbstractSequence<?>>();
sequences.putAll(FastaReaderHelper.readFastaProteinSequence(new File("C:/Users/Davide/Downloads/nvulgaris_29421_protein.faa")));
System.out.println("BLAST!!");
RunSimilaritySearch run_similaritySearch = new RunSimilaritySearch(tcdbGenes, 0.1,
Method.SmithWaterman, sequences, new AtomicBoolean(false), new AtomicInteger(0), new AtomicInteger(0), AlignmentScoreType.ALIGNMENT);
run_similaritySearch.setTcdbFastaFilePath(tcdbFastaFile);
run_similaritySearch.addObserver(this);
run_similaritySearch.setCurrentTempFolderDirectory(filePath);
//////set temp directory here!!!
ConcurrentLinkedQueue<AlignmentCapsule> results = null;
if(sequences.keySet().size()>0)
results = run_similaritySearch.runBlastSearch(true);
System.out.println("BLAST PERFORMED!!");
sequences.putAll(FastaReaderHelper.readFastaProteinSequence(new File("C:/Users/Davide/Downloads/nvulgaris_29421_protein.faa")));
logger.info("Blast process initialized!");
RunSimilaritySearch run_similaritySearch = new RunSimilaritySearch(tcdbGenes, 0.1,
Method.SmithWaterman, sequences, new AtomicBoolean(false), new AtomicInteger(0), new AtomicInteger(0), AlignmentScoreType.ALIGNMENT);
run_similaritySearch.setTcdbFastaFilePath(tcdbFastaFile);
run_similaritySearch.addObserver(this);
run_similaritySearch.setCurrentTempFolderDirectory(filePath);
ConcurrentLinkedQueue<AlignmentCapsule> results = null;
if(sequences.keySet().size()>0)
results = run_similaritySearch.runBlastSearch(true);
return results;
}
/**
*
* @param url
* @return
* @throws Exception
*/
public static Map<String, AbstractSequence<?>> getTcdbInMapFormat() throws Exception {
InputStream tcdbInputStream = (new URL(TcdbExplorer.TCDB_FASTA_URL)).openStream();
BufferedReader br= new BufferedReader(new InputStreamReader(tcdbInputStream));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
sb.append(line.concat("\n"));
String theString = sb.toString().replace("</p>", "").replace("<p>", "").replace(">gnl|TC-DB|xxxxxx 3.A.1.205.14 \ndsfgdfg", "");
byte[] bytes = theString.getBytes("utf-8");
tcdbInputStream = new ByteArrayInputStream(bytes);
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(
tcdbInputStream,
//tcdbFile,
new GenericFastaHeaderParser<ProteinSequence,AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
// System.out.println("CHECK3---->"+LocalDateTime.now().getHour()+":"+LocalDateTime.now().getMinute()+":"+LocalDateTime.now().getSecond());
Map<String, AbstractSequence<?>> tcdb = new HashMap<>();
tcdb.putAll(fastaReader.process());
return tcdb;
}
/**
*
* @param url
* @return
* @throws Exception
*/
public static Map<String, AbstractSequence<?>> getTcdbInMapFormat() throws Exception {
InputStream tcdbInputStream = (new URL(TcdbExplorer.TCDB_FASTA_URL)).openStream();
BufferedReader br= new BufferedReader(new InputStreamReader(tcdbInputStream));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
sb.append(line.concat("\n"));
String theString = sb.toString().replace("</p>", "").replace("<p>", "").replace(">gnl|TC-DB|xxxxxx 3.A.1.205.14 \ndsfgdfg", "");
byte[] bytes = theString.getBytes("utf-8");
tcdbInputStream = new ByteArrayInputStream(bytes);
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(
tcdbInputStream,
//tcdbFile,
new GenericFastaHeaderParser<ProteinSequence,AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
// System.out.println("CHECK3---->"+LocalDateTime.now().getHour()+":"+LocalDateTime.now().getMinute()+":"+LocalDateTime.now().getSecond());
Map<String, AbstractSequence<?>> tcdb = new HashMap<>();
tcdb.putAll(fastaReader.process());
return tcdb;
}
@Override
public void update(Observable arg0, Object arg1) {
// TODO Auto-generated method stub
}
/**
* @return
*/
public Map<String,List<AlignmentCapsule>> getAlignmentsByQuery(){
Map<String,List<AlignmentCapsule>> alignmentMap = new HashMap<>();
for(AlignmentCapsule alignContainer : this.results){
String query = alignContainer.getQuery();
if(alignmentMap.containsKey(query)){
alignmentMap.get(query).add(alignContainer);
}
else{
List<AlignmentCapsule> containersList = new ArrayList<>();
containersList.add(alignContainer);
alignmentMap.put(query, containersList);
}
}
return alignmentMap;
}
/**
* @return the results
*/
public ConcurrentLinkedQueue<AlignmentCapsule> getResults() {
return results;
}
}
......@@ -1495,88 +1495,12 @@ public class GenerateTransportReactions {
count++;
//any, except replacing ions
// if(!accept && !twoMetabolites) {
//
// if(metabolites.size() == 1) {
//
// for(String metabolite : metabolites) {
//
// for(String react : reactantMetabolites.keySet()) {
//
// // if(react.matches(""))
//
// if(!metabolite.matches("\\w+\\+") && !metabolite.matches("\\w+\\-")) {
//
// reactant = reactant.replace(reactantMetabolites.get(react), metabolite);
// accept = true;
// }
// break;
// }
//
// for(String prod : productMetabolites.keySet()) {
//
//
// if(!metabolite.matches("\\w+\\+") && !metabolite.matches("\\w+\\-")){
//
// // if(tc.equals("2.A.1.2.51 A3M9E9")) {
// // System.out.println(prod + "\t" + metabolite);
// // System.out.println(productMetabolites.get(prod));
// // System.out.println(product);
// // }
//
// product = product.replace(productMetabolites.get(prod), metabolite);
// accept = true;
//
// // if(tc.equals("2.A.1.2.51 A3M9E9"))
// // System.out.println(product);
// }
// break;
// }
// }
// }
// if(accept)
// confidenceLevel = count;
// }
count++;
// create new reactions
// if(!accept) {
//
//
//
// count++;
// implement elsewhere
// if(!accept) {
//
// String reaction ="";
//
// for(String metabolite : metabolites) {
// if(!metabolite.equals(TcdbMetabolitesContainer.PROTON) && !metabolite.equals(TcdbMetabolitesContainer.UNKNOWN) && !metabolite.equals(TcdbMetabolitesContainer.EMPTY)) {
//
// reaction = generateReactionFromMetabolites(transportType, metabolite);
//
// String[] aux = reaction.split(ReactionContainer.REV_TOKEN);
//
// reactant = aux[0];
// product = aux[1];
//
// accept = true;
// confidenceLevel = -2;
// }
// }
// }
if(accept) {
// if(tc.equals("2.A.1.3.67 Q9RSM6"))
// System.out.println(" cdcdcd " + confidenceLevel);
String[] result = new String[3];
result[0] = reactant.replaceAll("\\s+", " ").trim();
......@@ -1586,11 +1510,6 @@ public class GenerateTransportReactions {
return result;
}
// if(tc.equals("1.C.30.1.2 O32831"))
// System.out.println(metabolites);
return null;
}
......
package tcdb.triage;
import blast.Blast;
import tcdb.capsules.ReactionContainer;
public class Test {
public static void main(String[] args) {
new Blast();
}
}
#Generated by Maven Integration for Eclipse
#Wed Jul 04 14:15:37 BST 2018
#Fri Jul 06 12:51:19 BST 2018
m2e.projectLocation=C\:\\Users\\Davide\\Biosynth2\\triage
m2e.projectName=triage
groupId=tcdb
......
......@@ -16,13 +16,14 @@
<build>
<plugins>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> <configuration> <source>9</source> <target>9</target>
</configuration> </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.9</source>
<target>1.9</target>
<release>10</release>
</configuration>
</plugin>
</plugins>
......
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