...
 
Commits (9)
<component name="ArtifactManager">
<artifact type="war" name="DNAAnalysis_DHerzig:war">
<output-path>$PROJECT_DIR$/target</output-path>
<properties id="maven-jee-properties">
<options>
<module>DNAAnalysis_DHerzig</module>
<packaging>war</packaging>
</options>
</properties>
<root id="archive" name="DNAAnalysis_MES.war">
<element id="artifact" artifact-name="DNAAnalysis_DHerzig:war exploded" />
</root>
</artifact>
</component>
\ No newline at end of file
<component name="ArtifactManager">
<artifact type="exploded-war" name="DNAAnalysis_DHerzig:war exploded">
<output-path>$PROJECT_DIR$/target/DNAAnalysis_MES</output-path>
<properties id="maven-jee-properties">
<options>
<exploded>true</exploded>
<module>DNAAnalysis_DHerzig</module>
<packaging>war</packaging>
</options>
</properties>
<root id="root">
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="DNAAnalysis_DHerzig" />
</element>
<element id="directory" name="lib">
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-core:2.11.2" />
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" />
<element id="library" level="project" name="Maven: net.sourceforge.htmlunit:htmlunit:2.34.1" />
<element id="library" level="project" name="Maven: xalan:xalan:2.7.2" />
<element id="library" level="project" name="Maven: xalan:serializer:2.7.2" />
<element id="library" level="project" name="Maven: org.apache.commons:commons-lang3:3.8.1" />
<element id="library" level="project" name="Maven: org.apache.commons:commons-text:1.6" />
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpmime:4.5.7" />
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpclient:4.5.7" />
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" />
<element id="library" level="project" name="Maven: commons-codec:commons-codec:1.11" />
<element id="library" level="project" name="Maven: net.sourceforge.htmlunit:htmlunit-core-js:2.34.0" />
<element id="library" level="project" name="Maven: net.sourceforge.htmlunit:neko-htmlunit:2.34.0" />
<element id="library" level="project" name="Maven: xerces:xercesImpl:2.12.0" />
<element id="library" level="project" name="Maven: xml-apis:xml-apis:1.4.01" />
<element id="library" level="project" name="Maven: net.sourceforge.htmlunit:htmlunit-cssparser:1.3.0" />
<element id="library" level="project" name="Maven: commons-io:commons-io:2.6" />
<element id="library" level="project" name="Maven: commons-logging:commons-logging:1.2" />
<element id="library" level="project" name="Maven: commons-net:commons-net:3.6" />
<element id="library" level="project" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty:jetty-client:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty:jetty-http:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty:jetty-xml:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty:jetty-util:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty:jetty-io:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.4.15.v20190215" />
<element id="library" level="project" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.4.15.v20190215" />
</element>
</element>
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/target/DNAAnalysis_MES/META-INF/MANIFEST.MF" />
</element>
<element id="javaee-facet-resources" facet="DNAAnalysis_DHerzig/web/Web" />
</root>
</artifact>
</component>
\ No newline at end of file
......@@ -17,6 +17,11 @@
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......@@ -26,22 +31,62 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.2</version>
<version>2.8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.biojava/biojava-core -->
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.34.1</version>
<groupId>org.biojava</groupId>
<artifactId>biojava-core</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>DEV</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<server.username>admin</server.username>
<server.password>tomcat</server.password>
<server.url>localhost</server.url>
<server.port>8080</server.port>
</properties>
</profile>
<profile>
<id>PROD</id>
<properties>
<server.username>user</server.username>
<server.password>BiMRmi0E5t89</server.password>
<server.url>ec2-18-196-49-3.eu-central-1.compute.amazonaws.com</server.url>
<server.port>80</server.port>
</properties>
</profile>
</profiles>
<build>
<finalName>DNAAnalysis_MES</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.12</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>${server.username}</cargo.remote.username>
<cargo.remote.password>${server.password}</cargo.remote.password>
<cargo.hostname>${server.url}</cargo.hostname>
<cargo.servlet.port>${server.port}</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
......@@ -80,8 +125,14 @@
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</reporting>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
......
......@@ -5,6 +5,8 @@ import ch.fhnw.model.Sequence;
import ch.fhnw.util.DNAUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.biojava.nbio.core.sequence.DNASequence;
import org.biojava.nbio.core.sequence.ProteinSequence;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
......@@ -17,12 +19,8 @@ import java.util.ArrayList;
import java.util.List;
/**
*
* @author David Herzig
*/
@WebServlet(name = "analyzednaservlet", urlPatterns = { "/AnalyzeDNA", "/startApp" })
public class AnalyzeDNAServlet extends HttpServlet {
......@@ -35,22 +33,44 @@ public class AnalyzeDNAServlet extends HttpServlet {
String dna = req.getParameter("dnasequence");
String header = "";
if (dna != null) {
if (dna != null && dna.trim().startsWith(">")) {
header = dna.split("\\r?\\n")[0];
dna = dna.substring(header.length());
dna = dna.replace("\n", "").replace("\r", "");
}
Integer windowSize = 0;
Integer windowSize = 100;
try {
windowSize = Integer.parseInt(req.getParameter("windowsize"));
String str = req.getParameter("windowsize");
if (str != null) {
windowSize = Integer.parseInt(str);
}
} catch (Exception ex) {
LOG.error("Error occured when converting window size", ex);
}
System.out.println(dna);
System.out.println(windowSize);
System.out.println(header);
LOG.debug(dna);
LOG.debug(windowSize);
LOG.debug(header);
// usage of the biojava library
String informationStr = "";
if (dna != null && !dna.isEmpty()) {
try {
DNASequence bjSeq = new DNASequence(dna);
DNASequence.DNAType type = bjSeq.getDNAType();
int gcCount = bjSeq.getGCCount();
int length = bjSeq.getLength();
informationStr = "Header: " + header + "<br/>";
informationStr += "DNA Type: " + type.name() + "<br/>";
informationStr += "Length: " + length + "<br/>";
informationStr += "GC Count: " + gcCount;
} catch (Exception ex) {
LOG.error("Issues on using biojava " + ex.getMessage(), ex);
}
}
req.setAttribute("informationStr", informationStr);
LOG.debug(dna);
LOG.debug(windowSize);
......
package ch.fhnw.model;
public class Counter {
private int value;
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public int getValueAndIncrease() {
value = value + 1;
return value;
}
}
......@@ -9,6 +9,11 @@ public class Information {
private String coloredDNA;
private int index;
private int windowSize;
private long reqTime;
public long getReqTime() { return reqTime; }
public void setReqTime(long reqTime) { this.reqTime = reqTime; }
public String getColoredDNA() {
return coloredDNA;
......
......@@ -46,7 +46,7 @@ public class Sequence {
result.put(Sequence.A, count(Sequence.A));
result.put(Sequence.C, count(Sequence.C));
result.put(Sequence.G, count(Sequence.T));
result.put(Sequence.G, count(Sequence.G));
result.put(Sequence.T, count(Sequence.T));
return result;
......
......@@ -2,6 +2,7 @@ package ch.fhnw.util;
import ch.fhnw.model.Information;
import ch.fhnw.model.Sequence;
import jdk.internal.org.jline.utils.Log;
import java.util.ArrayList;
import java.util.List;
......@@ -18,13 +19,16 @@ public class DNAUtil {
* @return as described
*/
public static List<Information> analyze(Sequence seq, int windowSize, float lowerLimit, float upperLimit) {
long startTime = System.currentTimeMillis();
List<Information> result = new ArrayList<>();
int lowerAmount = (int)(lowerLimit * windowSize);
int upperAmount = (int)(upperLimit * windowSize);
for (int i=0; i<seq.getRawData().length()-windowSize+1; i++) {
String dnaWindow = seq.getRawData().substring(i, i+100);
String rawSequence = seq.getRawData();
for (int i=0; i<rawSequence.length()-windowSize+1; i++) {
String dnaWindow = rawSequence.substring(i, i+windowSize);
Sequence windowSeq = new Sequence(dnaWindow);
Map<String, Integer> count = windowSeq.countAll();
......@@ -61,6 +65,9 @@ public class DNAUtil {
infoObj.setColoredDNA(coloredSequence);
}
long endTime = System.currentTimeMillis();
result.get(result.size()-1).setReqTime(endTime-startTime);
Log.info("Time required for analysis:" +(endTime-startTime)+ " miliseconds");
return result;
}
......
package ch.fhnw.util;
public class SequenceValidator {
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<File name="MyDebugFile" fileName="dnaanalyze.log">
<File name="FileOutput" fileName="dnaanalyze.log">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
</File>
<Console name="ConsoleOutput" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="MyDebugFile"/>
<AppenderRef ref="FileOutput"/>
<AppenderRef ref="ConsoleOutput" />
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
......@@ -3,17 +3,80 @@
<head>
<meta charset="UTF-8">
<title>DNA Analyzer Application</title>
<style>
body {
text-align:center;
}
</style>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<!--
<h1>DNA Analysis</h1>
<form method="post" action="startApp" id="startApp" name="startApp">
<input type="submit" value="Start Application">
</form>
<h2>Resources</h2>
<button onclick="location.href='http://www.ncbi.nlm.nih.gov'" type="button">Visit NCBI page</button>
-->
<div class="container-md">
<div class="page-header">
<h1>
<img src = "images/fhnw_logo.png" class = "img-rounded" width="60">
MSC Medical Informatics
<br/><img src = "images/dna_icon.jpg" class = "img-rounded" width="60">
<small>DNA Analysis Application</small>
</h1>
</div>
<p class="text-justify">
This web application has been developed during the software engineering
lectures for the master medical informatics degree course.
</p>
<p class="h2">
<form method="post" action="startApp" id="startApp" name="startApp">
<button type="submit" class="btn btn-primary">Start Application</button>
</form>
</p>
<p class="h2">
Resources
</p>
<p class="text-justify">
<ul class="list-group">
<li class="list-group-item list-group-item-primary">National Center for Biotechnology Information (<a href="https://www.ncbi.nlm.nih.gov/" target="_new">https://www.ncbi.nlm.nih.gov/</a>)</li>
<li class="list-group-item list-group-item-secondary">Ensembl (<a href="https://www.ensembl.org/" target="_new">https://www.ensembl.org/</a>)</li>
</ul>
</p>
<p class="h2">
Technologies
</p>
<p class="text-justify">
<ul class="list-group">
<li class="list-group-item list-group-item-primary">Java (Programming Language) (<a href="https://www.oracle.com/java/" target="_new">https://www.oracle.com/java/</a>)</li>
<li class="list-group-item list-group-item-secondary">Apache ANT (Build Tool) (<a href="https://ant.apache.org/" target="_new">https://ant.apache.org/</a>)</li>
<li class="list-group-item list-group-item-primary">Apache Maven (Build Tool) (<a href="https://maven.apache.org/" target="_new">https://maven.apache.org/</a>)</li>
<li class="list-group-item list-group-item-secondary">Apache Tomcat (Application Server) (<a href="https://tomcat.apache.org/" target="_new">https://tomcat.apache.org/</a>)</li>
<li class="list-group-item list-group-item-primary">JUnit (Testing Tool) (<a href="https://junit.org/" target="_new">https://junit.org/</a>)</li>
<li class="list-group-item list-group-item-secondary">IntelliJ (Development Environment) (<a href="https://www.jetbrains.com/de-de/idea/" target="_new">https://www.jetbrains.com/de-de/idea/</a>)</li>
<li class="list-group-item list-group-item-primary">Eclipse (Development Environment) (<a href="https://www.eclipse.org/" target="_new">https://www.eclipse.org/</a>)</li>
<li class="list-group-item list-group-item-secondary">Git (Version Control) (<a href="https://git-scm.com/" target="_new">https://git-scm.com/</a>)</li>
<li class="list-group-item list-group-item-primary">Bootstrap (HTML Library) (<a href="https://getbootstrap.com/" target="_new">https://getbootstrap.com/</a>)</li>
<li class="list-group-item list-group-item-secondary">JQuery (Javascript Library) (<a href="https://jquery.com/" target="_new">https://jquery.com/</a>)</li>
<li class="list-group-item list-group-item-primary">Unified Modeling Language (UML) (<a href="https://www.uml.org/" target="_new">https://www.uml.org/</a>)</li>
<li class="list-group-item list-group-item-secondary">Apache Log4J 2 (Logging Library) (<a href="https://logging.apache.org/log4j/2.x/" target="_new">https://logging.apache.org/log4j/2.x/</a>)</li>
<li class="list-group-item list-group-item-primary">Jenkins (Continuous Integration) (<a href="https://www.jenkins.io/" target="_new">https://www.jenkins.io/</a>)</li>
<li class="list-group-item list-group-item-secondary">Apache JMeter (Testing Tool) (<a href="https://jmeter.apache.org/" target="_new">https://jmeter.apache.org/</a>)</li>
<li class="list-group-item list-group-item-primary">BioJava (<a href="https://biojava.org/" target="_new">https://biojava.org/</a>)</li>
</ul>
</p>
<p class="h2">
Source Code
</p>
<p class="text-justify">
The source code for this application is available on Git:<br/>
<a href="https://gitlab.fhnw.ch/david.herzig/dnaanalyzerwa" target="_new">https://gitlab.fhnw.ch/david.herzig/dnaanalyzerwa</a><br/>
<code>git clone https://gitlab.fhnw.ch/david.herzig/dnaanalyzerwa.git</code>
</p>
</div>
</body>
</html>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page import ="java.util.*,ch.fhnw.model.*,ch.fhnw.util.*" %>
<!DOCTYPE html>
<html>
<head>
<title>DNA Analyzer Application</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<!--
<link rel="stylesheet" href='<c:url value="/scripts/bootstrap.min.css"/>' />
<script type="text/javascript" src='<c:url value="/scripts/jquery-3.5.1.min.js"/>'></script>
<script type="text/javascript" src='<c:url value="/scripts/bootstrap.min.js"/>'></script>
-->
<style>
body {
text-align:center;
}
.modal-body{
word-break: break-all;
}
</style>
</head>
<body>
<h1>
DNA Analysis
</h1>
Enter DNA Sequence<br/>
<textarea rows="20" cols="200" name="dnasequence" form="addform"></textarea><br/>
Window Size<br/>
<input type="text" value="100" name="windowsize" form="addform"></input>
<div class="container-md">
<div class="page-header">
<h1>
<img src = "images/fhnw_logo.png" class = "img-rounded" width="60">
MSC Medical Informatics
<br/><img src = "images/dna_icon.jpg" class = "img-rounded" width="60">
<small>DNA Analysis Application</small>
</h1>
</div>
<p class="text-justify">
<textarea placeholder="Place DNA sequence here..." form="addform" name="dnasequence" class="form-control rounded-0" id="exampleFormControlTextarea1" rows="10"></textarea>
</p>
<p class="text-justify">
Window Size<br/>
<input class="form-control" name="windowsize" type="text" value="100" form="addform"></input>
</p>
<p class="text-justify">
<form method="post" action="AnalyzeDNA" id="addform">
<button type="submit" class="btn btn-primary">Analyse</button>
</form>
</p>
<br/><br/>
<br/>
<% if (!request.getAttribute("informationStr").toString().isEmpty()) { %>
<div class="alert alert-dark" role="alert">
<% out.println(request.getAttribute("informationStr")); %>
</div>
<% } %>
<br/>
<form method="post" action="AnalyzeDNA" id="addform">
<input type="submit" value="Analyse"><br/>
</form>
<div>
<br/><br/>
<h2 font-size = "32px"; >
<% out.println(request.getAttribute("header")); %>
</h2>
<br/><br/>
<br/><br/>
<h2 font-size = "32px"; >
<% out.println(request.getAttribute("header")); %>
</h2>
<br/><br/>
<%
List result= (List) request.getAttribute("analyzeresult");
Iterator it = result.iterator();
long reqTime = 0;
if (!result.isEmpty()){
Information info = (Information)result.get(result.size()-1);
reqTime = info.getReqTime();
out.println("Required time for analysis: " + reqTime + " miliseconds");
}else {
out.println("Start analyzing today!");
}
%>
<table>
<% if (it.hasNext()) { %>
<jsp:useBean id="counter" class="ch.fhnw.model.Counter" />
<jsp:setProperty name="counter" property="value" value="1"/>
<table class="table">
<thead class="thead-dark">
<tr>
<th>Start Index</th>
<th>A</th>
<th>C</th>
<th>G</th>
<th>T</th>
<th>Sequence</th>
</tr>
<% if (it.hasNext()) { %>
<th scope="col">Start Index</th>
<th scope="col">A</th>
<th scope="col">C</th>
<th scope="col">G</th>
<th scope="col">T</th>
<th scope="col">Sequence</th>
<% } %>
</tr>
</thead>
<tbody>
<%
while(it.hasNext()){
Information obj = (Information)it.next();
out.println("<tr>");
out.println("<td>" + obj.getIndex() + "</th>");
out.println("<td>" + obj.getSeq().count("A") + "</th>");
out.println("<td>" + obj.getSeq().count("C") + "</th>");
out.println("<td>" + obj.getSeq().count("G") + "</th>");
out.println("<td>" + obj.getSeq().count("T") + "</th>");
out.println("<td>" + obj.getColoredDNA() + "</th>");
out.println("<th scope=\"row\">" + obj.getIndex() + "</th>");
out.println("<td>" + obj.getSeq().count("A") + "</td>");
out.println("<td>" + obj.getSeq().count("C") + "</td>");
out.println("<td>" + obj.getSeq().count("G") + "</td>");
out.println("<td>" + obj.getSeq().count("T") + "</td>");
%>
<td>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#sequenceDialog_${counter.valueAndIncrease}">Sequence</button>
<div class="modal fade" id="sequenceDialog_${counter.value}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sequence</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<% out.println(obj.getColoredDNA()); %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</td>
<%
out.println("</tr>");
}
%>
</tbody>
</table>
<!-- Modal -->
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.