Skip to content

Commit

Permalink
Update args4j
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMELIUS committed Oct 12, 2015
1 parent 2fc6c28 commit 38d547c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/script/BioMart2Bdb.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void parse(BufferedReader br, String externalSource) throws IOException{
|| externalSource.equals("uniprot_swissprot")){
externalSource="uniprot_sptrembl";
}
System.out.println(split[1]);
System.out.println("Downloading:" +split[1]);
ds = DataSource.getExistingByFullName(bio.getReference(externalSource).get(0).getGpmlName());
line = br.readLine(); //Skip the header
while (line != null) {
Expand Down
148 changes: 118 additions & 30 deletions src/script/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,39 @@
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.BooleanOptionHandler;

import org.bridgedb.IDMapperException;
import org.bridgedb.Xref;
import org.bridgedb.bio.DataSourceTxt;
import org.bridgedb.tools.qc.BridgeQC;
import org.wikipathways.reportbots.OutdatedIdsReport;

public class Main {
@Option(name = "-q", aliases = {"--qc"}, usage = "Affiche l'aide")
private static boolean qc;

@Option(name = "-i", aliases = {"--inclusive"}, usage = "Affiche la version")
private static boolean inclusive;

@Argument
private List<String> argument;

protected static Logger logger;

private static void printUsage() {
System.out.println("Usage: java -jar BioMart2BridgeDb.jar <configurationFile> <newDatabase> "
+ "(optional)<QC> (optional)<inclusive>");
System.out.println("<configurationFile> location of configuration file");
System.out.println("<newDatabase> location for the new database");
System.out.println("<QC> (optional) directory of the old database - run QC");
System.out.println("<inclusive> (optional) use inclusive BridgeDb list");
}

/**
* java -jar BioMart2BridgeDb.jar arg1 arg2 arg3 arg4
* arg1: location of configuration file
Expand All @@ -37,42 +61,104 @@ public static void main(String[] args)
throws ClassNotFoundException, IDMapperException, IOException {
logInit();
DataSourceTxt.init(); //Initialize BrideDb data source
File dir = new File (args[0]);
String path = args[1];
File dir = null;
String path = null;
String pathOld = null;
Boolean qc = false;
Boolean include = false;
// Boolean qc = false;
// Boolean inclusive = false;

switch (args.length) {
case 3: pathOld = args[2];
qc = true;
break;
case 4: include = true;
break;
}
if (dir.isDirectory()){
FilenameFilter textFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
String lowercaseName = name.toLowerCase();
if (lowercaseName.endsWith(".config")) {
return true;
} else {
return false;
case 0: printUsage();
break;
case 1: printUsage();
break;
case 2: dir = new File (args[0]);
path = args[1];
if (dir.isDirectory()){
FilenameFilter textFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
String lowercaseName = name.toLowerCase();
if (lowercaseName.endsWith(".config")) {
return true;
} else {
return false;
}
}
};
File[] listFiles = dir.listFiles(textFilter);
for(File f : listFiles){
SpeciesConfiguration config = new SpeciesConfiguration(f.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
};
File[] listFiles = dir.listFiles(textFilter);
for(File f : listFiles){
SpeciesConfiguration config = new SpeciesConfiguration(f.getAbsolutePath());
runDB(config, path,include);
if (qc) report(false,pathOld,path,config);
OutdatedIdsReport.writeAll("All_ids.tsv");
}
OutdatedIdsReport.writeAll("All_ids.tsv");
}
else{
SpeciesConfiguration config = new SpeciesConfiguration(dir.getAbsolutePath());
runDB(config, path,include);
if (qc) report(false,pathOld,path,config);
else{
SpeciesConfiguration config = new SpeciesConfiguration(dir.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
break;
case 3:
dir = new File (args[0]);
path = args[1];
pathOld = args[2];
qc = true;
if (dir.isDirectory()){
FilenameFilter textFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
String lowercaseName = name.toLowerCase();
if (lowercaseName.endsWith(".config")) {
return true;
} else {
return false;
}
}
};
File[] listFiles = dir.listFiles(textFilter);
for(File f : listFiles){
SpeciesConfiguration config = new SpeciesConfiguration(f.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
OutdatedIdsReport.writeAll("All_ids.tsv");
}
else{
SpeciesConfiguration config = new SpeciesConfiguration(dir.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
break;
case 4:
dir = new File (args[0]);
path = args[1];
pathOld = args[2];
inclusive = true;
if (dir.isDirectory()){
FilenameFilter textFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
String lowercaseName = name.toLowerCase();
if (lowercaseName.endsWith(".config")) {
return true;
} else {
return false;
}
}
};
File[] listFiles = dir.listFiles(textFilter);
for(File f : listFiles){
SpeciesConfiguration config = new SpeciesConfiguration(f.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
OutdatedIdsReport.writeAll("All_ids.tsv");
}
else{
SpeciesConfiguration config = new SpeciesConfiguration(dir.getAbsolutePath());
runDB(config, path,inclusive);
if (qc) report(false,pathOld,path,config);
}
break;
}
}

Expand Down Expand Up @@ -101,6 +187,7 @@ public static void runDB(SpeciesConfiguration config,String path, Boolean inducl
QueryBioMart.loadBiomartAttributes(bio,config);
BioMart2Bdb mart = new BioMart2Bdb(config,bio,dbEntries,geneSet);

System.out.println("Start to download each datasources");
// Probe queries
try{
for (String probe:config.getProbeSet()){
Expand All @@ -124,6 +211,7 @@ public static void runDB(SpeciesConfiguration config,String path, Boolean inducl
mart.query(ds,true,true);
}
System.out.println(date);
System.out.println("Start to the creation of the database, might take some time");
mart.bridgedbCreator(dbEntries,geneSet,path);
System.out.println(date);
}
Expand Down
4 changes: 2 additions & 2 deletions src/script/QueryBioMart.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static InputStream getDataStream(Document xml, String endpoint) {
encodedXml = URLEncoder.encode(encodedXml, "UTF-8"); // encode to url
URL url = new URL(endpoint+"martservice/result?query=" + encodedXml);

System.out.println("Biomart query URL: " + url.toString());

// System.out.println("Biomart query URL: " + url.toString());
// logger.info("Biomart query URL: " + url.toString());
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
urlc.setDoOutput(true);
int code = urlc.getResponseCode();
Expand Down
3 changes: 3 additions & 0 deletions src/script/SpeciesConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ public class SpeciesConfiguration {
private Properties prop;
private InputStream input;
// static String includeList = "En,Mb,L,X,Il,Ag,Q,Om,U,Rf,S,Ip,T,Pd,H,M,R,D,Z,F,W,Gg,A,Ti,Ir,N,Uc,Pl,Gm,Bg,Ec,Wg,Gw,Kg,Bc,Tb";

private static String includeList = "Ensembl,miRBase Sequence,Entrez Gene,Affy,Illumina,Agilent,RefSeq,OMIM,"
+ "UniGene,Rfam,Uniprot-TrEMBL,IPI,GeneOntology,PDB,HGNC,MGI,RGD,SGD,ZFIN,FlyBase,WormBase,Gramene Genes DB,"
+ "TAIR,TIGR,IRGSP Gene,NASC Gene,UCSC Genome Browser,PlantGDB,BioGrid,EcoGene,WikiGenes,Gene Wiki,KEGG Genes,"
+ "BioCyc,TubercuList,Uniprot-SwissProt";

private Logger logger = Logger.getLogger("Bdb_creation");

public SpeciesConfiguration(String filename){
prop = new Properties();
// prop.stringPropertyNames();
Expand Down

0 comments on commit 38d547c

Please sign in to comment.