private void checkWriteFile ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , boolean dbsearch ) throws IOException , ClassNotFoundException , NoSuchMethodException , InvocationTargetException , IllegalAccessException , StructureException { String output = null ; if ( params . isOutputPDB ( ) ) { if ( ! GuiWrapper . isGuiModuleInstalled ( ) ) { System . err . println ( "The biojava-structure-gui module is not installed. Please install!" ) ; output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } else { Structure tmp = AFPAlignmentDisplay . createArtificalStructure ( afpChain , ca1 , ca2 ) ; output = "TITLE " + afpChain . getAlgorithmName ( ) + " " + afpChain . getVersion ( ) + " " ; output += afpChain . getName1 ( ) + " vs. " + afpChain . getName2 ( ) ; output += newline ; output += tmp . toPDB ( ) ; } } else if ( params . getOutFile ( ) != null ) { // output by default is XML // write the XML to a file... output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } else if ( params . getSaveOutputDir ( ) != null ) { output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } // no output requested. if ( output == null ) return ; String fileName = null ; if ( dbsearch ) { if ( params . getSaveOutputDir ( ) != null ) { // we currently don't have a naming convention for how to store results for custom files // they will be re-created on the fly if ( afpChain . getName1 ( ) . startsWith ( "file:" ) || afpChain . getName2 ( ) . startsWith ( "file:" ) ) return ; fileName = params . getSaveOutputDir ( ) ; fileName += getAutoFileName ( afpChain ) ; } else { return ; } // //else { // fileName = getAutoFileName(afpChain); //} } else if ( params . getOutFile ( ) != null ) { fileName = params . getOutFile ( ) ; } if ( fileName == null ) { System . err . println ( "Can't write outputfile. Either provide a filename using -outFile or set -autoOutputFile to true ." ) ; System . exit ( 1 ) ; return ; } //System.out.println("writing results to " + fileName + " " + params.getSaveOutputDir()); FileOutputStream out ; // declare a file output object PrintStream p ; // declare a print stream object // Create a new file output stream out = new FileOutputStream ( fileName ) ; // Connect print stream to the output stream p = new PrintStream ( out ) ; p . println ( output ) ; p . close ( ) ; }
check if the result should be written to the local file system