7474 *
7575 * @author Andreas
7676 * @author Spencer
77- *
7877 */
7978public abstract class AbstractUserArgumentProcessor implements UserArgumentProcessor {
8079
81- public static String newline = System .getProperty ( "line.separator" );
80+ public static String newline = System .lineSeparator ( );
8281
8382 protected StartupParameters params ;
8483
@@ -109,11 +108,6 @@ public void process(String[] argv){
109108
110109 printAboutMe ();
111110
112- // if(argv.length == 0 ) {
113- // System.out.println(printHelp());
114- // return;
115- // }
116-
117111 for (int i = 0 ; i < argv .length ; i ++){
118112 String arg = argv [i ];
119113
@@ -144,8 +138,6 @@ public void process(String[] argv){
144138
145139 String [] tmp = {arg ,value };
146140
147- //System.out.println(arg + " " + value);
148-
149141 try {
150142
151143 CliTools .configureBean (params , tmp );
@@ -177,7 +169,6 @@ public void process(String[] argv){
177169 String pdb1 = params .getPdb1 ();
178170 String file1 = params .getFile1 ();
179171
180-
181172 try {
182173 if (pdb1 != null || file1 != null ){
183174 runPairwise ();
@@ -195,90 +186,76 @@ public void process(String[] argv){
195186 System .exit (1 ); return ;
196187 }
197188
198-
199-
200-
201-
202189 public static void printAboutMe () {
203- try {
204- ResourceManager about = ResourceManager .getResourceManager ("about" );
205-
206- String version = about .getString ("project_version" );
207- String build = about .getString ("build" );
208-
209- System .out .println ("Protein Comparison Tool " + version + " " + build );
210- } catch (Exception e ){
211- e .printStackTrace ();
212- }
190+ ResourceManager about = ResourceManager .getResourceManager ("about" );
213191
192+ String version = about .getString ("project_version" );
193+ String build = about .getString ("build" );
214194
195+ System .out .println ("Protein Comparison Tool " + version + " " + build );
215196 }
216197
217- private void runAlignPairs (AtomCache cache , String alignPairs ,
218- String outputFile ) {
219- try {
220- File f = new File (alignPairs );
198+ private void runAlignPairs (AtomCache cache , String alignPairs , String outputFile ) throws IOException , StructureException , ClassNotFoundException , InvocationTargetException , NoSuchMethodException , IllegalAccessException {
221199
222- BufferedReader is = new BufferedReader ( new InputStreamReader ( new FileInputStream ( f )) );
200+ File f = new File ( alignPairs );
223201
224- BufferedWriter out = new BufferedWriter (new FileWriter ( outputFile , true ));
202+ BufferedReader is = new BufferedReader (new InputStreamReader ( new FileInputStream ( f ) ));
225203
226- StructureAlignment algorithm = getAlgorithm ( );
204+ BufferedWriter out = new BufferedWriter ( new FileWriter ( outputFile , true ) );
227205
228- String header = "# algorithm:" + algorithm .getAlgorithmName ();
229- out .write (header );
230- out .write (newline );
206+ StructureAlignment algorithm = getAlgorithm ();
231207
232- out .write ("#Legend: " + newline );
233- String legend = getDbSearchLegend ();
234- out .write (legend + newline );
235- System .out .println (legend );
236- String line = null ;
237- while ( (line = is .readLine ()) != null ){
238- if ( line .startsWith ("#" ))
239- continue ;
208+ String header = "# algorithm:" + algorithm .getAlgorithmName ();
209+ out .write (header );
210+ out .write (newline );
240211
241- String [] spl = line .split (" " );
212+ out .write ("#Legend: " + newline );
213+ String legend = getDbSearchLegend ();
214+ out .write (legend + newline );
215+ System .out .println (legend );
216+ String line = null ;
217+ while ( (line = is .readLine ()) != null ){
218+ if ( line .startsWith ("#" ))
219+ continue ;
242220
243- if ( spl .length != 2 ) {
244- System .err .println ("wrongly formattted line. Expected format: 4hhb.A 4hhb.B but found " + line );
245- continue ;
246- }
221+ String [] spl = line .split (" " );
247222
248- String pdb1 = spl [0 ];
249- String pdb2 = spl [1 ];
223+ if ( spl .length != 2 ) {
224+ System .err .println ("wrongly formattted line. Expected format: 4hhb.A 4hhb.B but found " + line );
225+ continue ;
226+ }
250227
228+ String pdb1 = spl [0 ];
229+ String pdb2 = spl [1 ];
251230
252- Structure structure1 = cache .getStructure (pdb1 );
253- Structure structure2 = cache .getStructure (pdb2 );
254231
255- Atom [] ca1 ;
256- Atom [] ca2 ;
232+ Structure structure1 = cache . getStructure ( pdb1 ) ;
233+ Structure structure2 = cache . getStructure ( pdb2 ) ;
257234
235+ Atom [] ca1 ;
236+ Atom [] ca2 ;
258237
259- ca1 = StructureTools .getRepresentativeAtomArray (structure1 );
260- ca2 = StructureTools .getRepresentativeAtomArray (structure2 );
261238
262- Object jparams = getParameters ();
239+ ca1 = StructureTools .getRepresentativeAtomArray (structure1 );
240+ ca2 = StructureTools .getRepresentativeAtomArray (structure2 );
263241
264- AFPChain afpChain ;
242+ Object jparams = getParameters () ;
265243
266- afpChain = algorithm .align (ca1 , ca2 , jparams );
267- afpChain .setName1 (pdb1 );
268- afpChain .setName2 (pdb2 );
244+ AFPChain afpChain ;
269245
270- String result = getDbSearchResult ( afpChain );
271- out . write ( result );
272- System . out . print ( result );
246+ afpChain = algorithm . align ( ca1 , ca2 , jparams );
247+ afpChain . setName1 ( pdb1 );
248+ afpChain . setName2 ( pdb2 );
273249
274- checkWriteFile (afpChain ,ca1 ,ca2 ,true );
275- }
250+ String result = getDbSearchResult (afpChain );
251+ out .write (result );
252+ System .out .print (result );
276253
277- out .close ();
278- is .close ();
279- } catch (Exception e ){
280- e .printStackTrace ();
254+ checkWriteFile (afpChain ,ca1 ,ca2 ,true );
281255 }
256+
257+ out .close ();
258+ is .close ();
282259 }
283260
284261
@@ -411,9 +388,6 @@ private void runPairwise() throws ConfigurationException{
411388
412389 checkWriteFile (afpChain ,ca1 , ca2 , false );
413390
414-
415-
416-
417391 if ( params .isPrintXML ()){
418392 String fatcatXML = AFPChainXMLConverter .toXML (afpChain ,ca1 ,ca2 );
419393 System .out .println (fatcatXML );
@@ -426,26 +400,12 @@ private void runPairwise() throws ConfigurationException{
426400 System .out .println (afpChain .toCE (ca1 , ca2 ));
427401 }
428402
429- } catch (IOException e ) {
430- e .printStackTrace ();
431- System .exit (1 ); return ;
432- } catch (ClassNotFoundException e ) {
433- e .printStackTrace ();
434- System .exit (1 ); return ;
435- } catch (NoSuchMethodException e ) {
436- e .printStackTrace ();
437- System .exit (1 ); return ;
438- } catch (InvocationTargetException e ) {
439- e .printStackTrace ();
440- System .exit (1 ); return ;
441- } catch (IllegalAccessException e ) {
442- e .printStackTrace ();
443- System .exit (1 ); return ;
444- } catch (StructureException e ) {
403+ } catch (IOException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
404+ IllegalAccessException | StructureException e ) {
445405 e .printStackTrace ();
446406 System .exit (1 ); return ;
447407 }
448- }
408+ }
449409
450410 /**
451411 * check if the result should be written to the local file system
0 commit comments