-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 79d89b7
Showing
23 changed files
with
1,024 additions
and
0 deletions.
There are no files selected for viewing
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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="lib" path="C:/lib/commons-codec-1.11/commons-codec-1.11.jar"/> | ||
<classpathentry kind="lib" path="C:/lib/ftp4j-1.7.2/ftp4j-1.7.2.jar"/> | ||
<classpathentry kind="lib" path="C:/lib/commons-io-2.6/commons-io-2.6.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ENAuploader</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
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.source=1.8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,52 @@ | ||
package eu.europa.ecdc.enauploader; | ||
import java.io.File; | ||
|
||
public abstract class DatabaseEntity { | ||
|
||
String title; | ||
String accession; | ||
String centerName; | ||
String alias; | ||
File xmlFile; | ||
String type; | ||
|
||
DatabaseEntity(String c, String a) { | ||
title = a; | ||
accession = ""; | ||
centerName=c; | ||
alias=a; | ||
|
||
} | ||
|
||
public void setAccession(String a) { | ||
accession = a; | ||
} | ||
public String getAccession() { | ||
return accession; | ||
} | ||
|
||
public void writeXml() { | ||
xmlFile = new File(ENAUtils.TMP_PATH+type+"_"+alias+".xml"); | ||
writeXml(xmlFile); | ||
} | ||
|
||
public abstract void writeXml(File f); | ||
|
||
public abstract String getSubmitRow(); | ||
|
||
public Object getXmlFile() { | ||
return xmlFile; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public String getAlias() { | ||
return alias; | ||
} | ||
|
||
|
||
|
||
|
||
} |
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,41 @@ | ||
package eu.europa.ecdc.enauploader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
import it.sauronsoftware.ftp4j.FTPAbortedException; | ||
import it.sauronsoftware.ftp4j.FTPClient; | ||
import it.sauronsoftware.ftp4j.FTPDataTransferException; | ||
import it.sauronsoftware.ftp4j.FTPException; | ||
import it.sauronsoftware.ftp4j.FTPIllegalReplyException; | ||
|
||
public class ENAUtils { | ||
|
||
public static final String FTP_HOST = "webin.ebi.ac.uk"; | ||
public static final String TMP_PATH = "C:/ENAtmp/"; | ||
public static final String CURL_PATH = "T:/Epidemiological Methods/MolecularSurveillance/Software/curl.exe"; | ||
|
||
|
||
public static void init() { | ||
File tmpDir = new File(TMP_PATH); | ||
tmpDir.mkdirs(); | ||
} | ||
|
||
|
||
|
||
public static String getTaxid(String taxon) { | ||
|
||
switch (taxon) { | ||
|
||
case "Listeria monocytogenes": | ||
return "1639"; | ||
case "Salmonella enterica": | ||
return "28901"; | ||
case "Escherichia coli": | ||
return "562"; | ||
default: | ||
return "0"; | ||
} | ||
} | ||
} |
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,103 @@ | ||
package eu.europa.ecdc.enauploader; | ||
import java.io.File; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
public class ENAuploaderMain { | ||
|
||
// This is a command line version | ||
public static void main(String[] args) { | ||
//args: | ||
//Center | ||
//Project id ("" means create new project) "PRJEB25143" | ||
//CSV file path | ||
//Data directory path | ||
// Login (Webin-NNNNN) | ||
// Password | ||
// yes/no whether to use the production database at EBI | ||
|
||
if (args.length < 4) { | ||
return; | ||
} | ||
|
||
String center = args[0]; | ||
String project = args[1]; | ||
File csvFile = new File(args[2]); | ||
File dataDir = new File(args[3]); | ||
|
||
String login = ""; | ||
String pass = ""; | ||
String prod = "no"; | ||
if (args.length > 5) { | ||
login = args[4]; | ||
pass = args[5]; | ||
} | ||
|
||
if (args.length > 6) { | ||
prod = args[6]; | ||
} | ||
|
||
SubmissionFactory.createSubmissionFromCSV(center,project, csvFile,dataDir, login, pass, prod); | ||
} | ||
|
||
|
||
//Example code for use of the library, rename to main to run it | ||
public static void main2(String[] args) { | ||
|
||
//Init tmp folder | ||
ENAUtils.init(); | ||
|
||
//base name for testing | ||
String randomUUIDString = UUID.randomUUID().toString(); | ||
String sname = "ECDCtest_"+randomUUIDString; | ||
|
||
//Create new submission | ||
Submission s = new Submission("ECDC","sub_"+sname); | ||
//s.SetLogin("login", "pwd"); //Use this to change credentials from ECDC test account | ||
//s.useProductionServer(false); //Use this to change between test and production on EBI | ||
//(Test submissions are deleted within 24 hours) | ||
|
||
//New project | ||
//Project p = new Project("ECDC","proj_"+sname); | ||
//s.addEntry(p); | ||
|
||
|
||
//New sample wrapper (includes sample, experiment and run) | ||
SampleWrapper wrap = new SampleWrapper("ECDC","PRJEB25143", sname); | ||
|
||
//Set minimal metadata | ||
wrap.sample.setAttribute("host_associated","yes"); | ||
wrap.sample.setAttribute("specific_host","human"); | ||
wrap.sample.setAttribute("host_disease_status","diseased"); | ||
wrap.sample.setAttribute("collected_by","ECDC"); | ||
wrap.sample.setAttribute("collection_date","2018"); | ||
wrap.sample.setAttribute("country","Sweden"); | ||
wrap.sample.setAttribute("serovar","unknown"); | ||
wrap.sample.setTaxon("Listeria monocytogenes"); | ||
wrap.experiment.setInstrument("Ion Torrent S5 XL"); | ||
|
||
//Add a sequence file | ||
wrap.run.addFile(new File("C:/ENAtmp/raw/MI-90_18b.fastq.gz")); | ||
|
||
//Add entries in wrapper to submission | ||
s.addEntry(wrap); | ||
|
||
//Upload files and submit | ||
s.uploadFiles(); | ||
s.submit(); | ||
|
||
|
||
//Test output | ||
//System.out.println(p.getAccession()); | ||
System.out.println(wrap.run.getAccession()); | ||
System.out.println(wrap.sample.getAccession()); | ||
System.out.println(wrap.experiment.getAccession()); | ||
for (File f : wrap.run.getOriginalFiles()) { | ||
System.out.println(f.toString()); | ||
} | ||
|
||
} | ||
|
||
} |
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,92 @@ | ||
package eu.europa.ecdc.enauploader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class Experiment extends DatabaseEntity { | ||
|
||
private String studyAccession; | ||
private String sampleAccession; | ||
|
||
private String pairedDistance; | ||
private String pairedDistanceSdev; | ||
|
||
private String instrument; | ||
|
||
Experiment(String c, String a, String studyAcc, String sampleAcc) { | ||
super(c, a); | ||
|
||
pairedDistance = "500"; | ||
pairedDistanceSdev = "200.0"; | ||
|
||
|
||
type = "EXPERIMENT"; | ||
studyAccession = studyAcc; | ||
sampleAccession = sampleAcc; | ||
} | ||
|
||
public void setInstrument(String instr) { | ||
instrument = instr; | ||
} | ||
|
||
@Override | ||
public void writeXml(File f) { | ||
BufferedWriter bw; | ||
try { | ||
bw = new BufferedWriter(new FileWriter(f)); | ||
bw.write("<?xml version = '1.0' encoding = 'UTF-8'?>\n"); | ||
bw.write("<EXPERIMENT_SET xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"ftp://ftp.sra.ebi.ac.uk/meta/xsd/sra_1_5/SRA.experiment.xsd\">\n"); | ||
bw.write("<EXPERIMENT alias=\""+alias+"\" center_name=\""+centerName+"\">\n"); | ||
bw.write("<TITLE>"+title+"</TITLE>\n"); | ||
if (studyAccession.startsWith("PRJ")) { | ||
bw.write("<STUDY_REF accession=\""+studyAccession+"\"/>\n"); | ||
} else { | ||
bw.write("<STUDY_REF refname=\""+studyAccession+"\"/>\n"); | ||
} | ||
|
||
bw.write("<DESIGN>\n"); | ||
bw.write("<DESIGN_DESCRIPTION>Whole genome sequencing of pathogens</DESIGN_DESCRIPTION>\n"); | ||
bw.write("<SAMPLE_DESCRIPTOR refname=\""+sampleAccession+"\"/>\n"); | ||
bw.write("<LIBRARY_DESCRIPTOR>\n"); | ||
bw.write("<LIBRARY_NAME>"+alias+"</LIBRARY_NAME>\n"); | ||
bw.write("<LIBRARY_STRATEGY>WGS</LIBRARY_STRATEGY>\n"); | ||
bw.write("<LIBRARY_SOURCE>GENOMIC</LIBRARY_SOURCE>\n"); | ||
bw.write("<LIBRARY_SELECTION>RANDOM</LIBRARY_SELECTION>\n"); | ||
bw.write("<LIBRARY_LAYOUT>\n"); | ||
if (instrument.matches(".*Illumina.*")) { | ||
bw.write("<PAIRED NOMINAL_LENGTH=\""+pairedDistance+"\" NOMINAL_SDEV=\""+pairedDistanceSdev+"\"/>\n"); | ||
} else { | ||
bw.write("<SINGLE/>\n"); | ||
} | ||
bw.write("</LIBRARY_LAYOUT>\n"); | ||
bw.write("<LIBRARY_CONSTRUCTION_PROTOCOL>unknown</LIBRARY_CONSTRUCTION_PROTOCOL>\n"); | ||
bw.write("</LIBRARY_DESCRIPTOR>\n"); | ||
bw.write("</DESIGN>\n"); | ||
bw.write("<PLATFORM>\n"); | ||
if (instrument.matches(".*Illumina.*")) { | ||
bw.write("<ILLUMINA>\n"); | ||
bw.write("<INSTRUMENT_MODEL>"+instrument+"</INSTRUMENT_MODEL>\n"); | ||
bw.write("</ILLUMINA>\n"); | ||
} else if(instrument.matches(".*Ion Torrent.*")) { | ||
bw.write("<ION_TORRENT>\n"); | ||
bw.write("<INSTRUMENT_MODEL>"+instrument+"</INSTRUMENT_MODEL>\n"); | ||
bw.write("</ION_TORRENT>\n"); | ||
} | ||
bw.write("</PLATFORM>\n"); | ||
bw.write("</EXPERIMENT>\n"); | ||
bw.write("</EXPERIMENT_SET>\n"); | ||
bw.close(); | ||
} catch (IOException e) { | ||
|
||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public String getSubmitRow() { | ||
return "<ADD schema=\"experiment\" source=\""+xmlFile.toString()+"\"/>"; | ||
} | ||
|
||
} |
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,45 @@ | ||
package eu.europa.ecdc.enauploader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class Project extends DatabaseEntity { | ||
|
||
|
||
String description; | ||
|
||
|
||
Project(String c, String a) { | ||
super(c,a); | ||
description = a; | ||
type = "PROJECT"; | ||
} | ||
|
||
public void writeXml(File projectFile) { | ||
|
||
BufferedWriter bw; | ||
try { | ||
bw = new BufferedWriter(new FileWriter(projectFile)); | ||
bw.write("<?xml version = '1.0' encoding = 'UTF-8'?>\n"); | ||
bw.write("<PROJECT_SET>\n"); | ||
bw.write("<PROJECT alias=\""+alias+"\" center_name=\""+centerName+"\">\n"); | ||
bw.write("<TITLE>"+title+"</TITLE>\n"); | ||
bw.write("<DESCRIPTION>"+description+"</DESCRIPTION>\n"); | ||
bw.write("<SUBMISSION_PROJECT>\n"); | ||
bw.write("<SEQUENCING_PROJECT/>\n"); | ||
bw.write("</SUBMISSION_PROJECT>\n"); | ||
bw.write("</PROJECT>\n"); | ||
bw.write("</PROJECT_SET>\n"); | ||
bw.close(); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public String getSubmitRow() { | ||
return "<ADD schema=\"project\" source=\""+xmlFile.toString()+"\"/>"; | ||
} | ||
|
||
} |
Oops, something went wrong.