Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@
*
* @author Andreas
* @author Spencer
*
*/
public abstract class AbstractUserArgumentProcessor implements UserArgumentProcessor {

public static String newline = System.getProperty("line.separator");
public static String newline = System.lineSeparator();

protected StartupParameters params ;

Expand Down Expand Up @@ -109,11 +108,6 @@ public void process(String[] argv){

printAboutMe();

// if(argv.length == 0 ) {
// System.out.println(printHelp());
// return;
// }

for (int i = 0 ; i < argv.length; i++){
String arg = argv[i];

Expand Down Expand Up @@ -144,8 +138,6 @@ public void process(String[] argv){

String[] tmp = {arg,value};

//System.out.println(arg + " " + value);

try {

CliTools.configureBean(params, tmp);
Expand Down Expand Up @@ -177,15 +169,17 @@ public void process(String[] argv){
String pdb1 = params.getPdb1();
String file1 = params.getFile1();


try {
if (pdb1 != null || file1 != null){
runPairwise();
return;
}


} catch (ConfigurationException e) {
if ( params.getAlignPairs() != null){
runAlignPairs();
return;
}
} catch (Exception e) {
System.err.println(e.getLocalizedMessage());
System.exit(1); return;
}
Expand All @@ -195,90 +189,103 @@ public void process(String[] argv){
System.exit(1); return;
}

public static void printAboutMe() {
ResourceManager about = ResourceManager.getResourceManager("about");

String version = about.getString("project_version");
String build = about.getString("build");

System.out.println("Protein Comparison Tool " + version + " " + build);
}

private void runAlignPairs() throws ConfigurationException, StructureException, IOException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {

public static void printAboutMe() {
try {
ResourceManager about = ResourceManager.getResourceManager("about");
String pdbFilePath = params.getPdbFilePath();

String version = about.getString("project_version");
String build = about.getString("build");
if ( pdbFilePath == null || pdbFilePath.equals("")){
UserConfiguration c = new UserConfiguration();
pdbFilePath = c.getPdbFilePath();
System.err.println("You did not specify the -pdbFilePath parameter. Defaulting to "+pdbFilePath+".");
}

System.out.println("Protein Comparison Tool " + version + " " + build);
} catch (Exception e){
e.printStackTrace();
AtomCache cache = new AtomCache(pdbFilePath, pdbFilePath);

String alignPairs = params.getAlignPairs();

if ( alignPairs == null || alignPairs.equals("")) {
throw new ConfigurationException("Please specify -alignPairs!");
}

String outputFile = params.getOutFile();

if ( outputFile == null || outputFile.equals("")){
throw new ConfigurationException("Please specify the mandatory argument -outFile!");
}

runAlignPairs(cache, alignPairs, outputFile);
}

private void runAlignPairs(AtomCache cache, String alignPairs,
String outputFile) {
try {
File f = new File(alignPairs);
private void runAlignPairs(AtomCache cache, String alignPairs, String outputFile) throws IOException, StructureException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {

BufferedReader is = new BufferedReader (new InputStreamReader(new FileInputStream(f)));
File f = new File(alignPairs);

BufferedWriter out = new BufferedWriter(new FileWriter(outputFile, true));
BufferedReader is = new BufferedReader (new InputStreamReader(new FileInputStream(f)));

StructureAlignment algorithm = getAlgorithm();
BufferedWriter out = new BufferedWriter(new FileWriter(outputFile, true));

String header = "# algorithm:" + algorithm.getAlgorithmName();
out.write(header);
out.write(newline);
StructureAlignment algorithm = getAlgorithm();

out.write("#Legend: " + newline );
String legend = getDbSearchLegend();
out.write(legend + newline );
System.out.println(legend);
String line = null;
while ( (line = is.readLine()) != null){
if ( line.startsWith("#"))
continue;
String header = "# algorithm:" + algorithm.getAlgorithmName();
out.write(header);
out.write(newline);

String[] spl = line.split(" ");
out.write("#Legend: " + newline );
String legend = getDbSearchLegend();
out.write(legend + newline );
System.out.println(legend);
String line = null;
while ( (line = is.readLine()) != null){
if ( line.startsWith("#"))
continue;

if ( spl.length != 2) {
System.err.println("wrongly formattted line. Expected format: 4hhb.A 4hhb.B but found " + line);
continue;
}
String[] spl = line.split(" ");

String pdb1 = spl[0];
String pdb2 = spl[1];
if ( spl.length != 2) {
System.err.println("wrongly formattted line. Expected format: 4hhb.A 4hhb.B but found " + line);
continue;
}

String pdb1 = spl[0];
String pdb2 = spl[1];

Structure structure1 = cache.getStructure(pdb1);
Structure structure2 = cache.getStructure(pdb2);

Atom[] ca1;
Atom[] ca2;
Structure structure1 = cache.getStructure(pdb1);
Structure structure2 = cache.getStructure(pdb2);

Atom[] ca1;
Atom[] ca2;

ca1 = StructureTools.getRepresentativeAtomArray(structure1);
ca2 = StructureTools.getRepresentativeAtomArray(structure2);

Object jparams = getParameters();
ca1 = StructureTools.getRepresentativeAtomArray(structure1);
ca2 = StructureTools.getRepresentativeAtomArray(structure2);

AFPChain afpChain;
Object jparams = getParameters();

afpChain = algorithm.align(ca1, ca2, jparams);
afpChain.setName1(pdb1);
afpChain.setName2(pdb2);
AFPChain afpChain;

String result = getDbSearchResult(afpChain);
out.write(result);
System.out.print(result);
afpChain = algorithm.align(ca1, ca2, jparams);
afpChain.setName1(pdb1);
afpChain.setName2(pdb2);

checkWriteFile(afpChain,ca1,ca2,true);
}
String result = getDbSearchResult(afpChain);
out.write(result);
System.out.print(result);

out.close();
is.close();
} catch(Exception e){
e.printStackTrace();
checkWriteFile(afpChain,ca1,ca2,true);
}

out.close();
is.close();
}


Expand Down Expand Up @@ -411,9 +418,6 @@ private void runPairwise() throws ConfigurationException{

checkWriteFile(afpChain,ca1, ca2, false);




if ( params.isPrintXML()){
String fatcatXML = AFPChainXMLConverter.toXML(afpChain,ca1,ca2);
System.out.println(fatcatXML);
Expand All @@ -426,26 +430,12 @@ private void runPairwise() throws ConfigurationException{
System.out.println(afpChain.toCE(ca1, ca2));
}

} catch (IOException e) {
e.printStackTrace();
System.exit(1); return;
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1); return;
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.exit(1); return;
} catch (InvocationTargetException e) {
e.printStackTrace();
System.exit(1); return;
} catch (IllegalAccessException e) {
e.printStackTrace();
System.exit(1); return;
} catch (StructureException e) {
} catch (IOException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
IllegalAccessException | StructureException e) {
e.printStackTrace();
System.exit(1); return;
}
}
}

/**
* check if the result should be written to the local file system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import org.biojava.nbio.structure.align.StructureAlignment;
import org.biojava.nbio.structure.align.ce.CeParameters.ScoringStrategy;

/** process the arguments from command line
/**
* Process the arguments from command line
*
* @author Andreas Prlic
*
Expand Down Expand Up @@ -154,7 +155,6 @@ public String toString() {
.append(showMenu).append(", printPDB=").append(printPDB)
.append(", isDomainSplit=").append(isDomainSplit)
.append(", alignPairs=").append(alignPairs)
.append(", searchFile=").append(searchFile)
.append(", saveOutputDir=").append(saveOutputDir)
.append(", nrCPU=").append(nrCPU).append("]");
return builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* A simple bean that contains the parameters that can get set at startup
*
* @author Andreas Prlic
*
*/
public class StartupParameters {

Expand All @@ -49,7 +48,6 @@ public class StartupParameters {

// for DB searches
String alignPairs;
String searchFile;
String saveOutputDir;
int nrCPU;

Expand All @@ -69,19 +67,8 @@ public StartupParameters(){
nrCPU = 1;
}

/** An input file to be used for the DB search
*
* @return
*/
public String getSearchFile() {
return searchFile;
}
public void setSearchFile(String searchFile) {
this.searchFile = searchFile;
}


/** The file that contains a list of PDB pairs to be aligned
/**
* The file that contains a list of PDB pairs to be aligned
*
* @return
*/
Expand Down Expand Up @@ -109,15 +96,17 @@ public void setShowMenu(boolean showMenu) {
this.showMenu = showMenu;
}

/** Display the output string in CE style
/**
* Display the output string in CE style
*
* @return flag
*/
public boolean isPrintCE() {
return printCE;
}

/** Display the output string in CE style
/**
* Display the output string in CE style
*
* @param printCE a flag
*/
Expand All @@ -129,7 +118,8 @@ public void setPrintCE(boolean printCE) {
public String getPdb1() {
return pdb1;
}
/** mandatory argument to set the first PDB (and optionally chain ID) to be aligned.
/**
* mandatory argument to set the first PDB (and optionally chain ID) to be aligned.
*
* @param pdb1
*/
Expand All @@ -140,7 +130,8 @@ public String getPdb2() {
return pdb2;
}

/** mandatory argument to set the second PDB (and optionally chain ID) to be aligned.
/**
* mandatory argument to set the second PDB (and optionally chain ID) to be aligned.
* @param pdb2
*/
public void setPdb2(String pdb2) {
Expand All @@ -164,7 +155,8 @@ public String getPdbFilePath() {
return pdbFilePath;
}

/** mandatory argument to set the location of PDB files.
/**
* mandatory argument to set the location of PDB files.
*
* @param pdbFilePath
*/
Expand Down Expand Up @@ -232,9 +224,8 @@ public void setFile2(String file2)
this.file2 = file2;
}



/** When writing the results to a file, don;t write as XML but write aligned PDB file
/**
* When writing the results to a file, don;t write as XML but write aligned PDB file
*
* @return flag
*/
Expand All @@ -249,10 +240,6 @@ public void setOutputPDB(boolean printPDB) {
this.printPDB = printPDB;
}





public boolean isDomainSplit() {
return isDomainSplit;
}
Expand All @@ -273,14 +260,8 @@ public String toString() {
+ ", " + newline + " printPDB=" + printPDB
+ ", " + newline + " isDomainSplit="
+ isDomainSplit + ", " + newline + " alignPairs=" + alignPairs
+ ", " + newline + " searchFile=" + searchFile + ", " + newline + " saveOutputDir="
+ ", " + newline + " saveOutputDir="
+ saveOutputDir + ", " + newline + " nrCPU=" + nrCPU + "]";
}







}