+
+ private static Map<String, String> readFastaFileIntoMap( final File mapping_infile, final boolean verbose ) {
+ List<MolecularSequence> seqs = null;
+ try {
+ seqs = FastaParser.parse( new FileInputStream( mapping_infile ) );
+ }
+ catch ( final IOException e ) {
+ ForesterUtil.fatalError( decorator.PRG_NAME, "failed to read fasta-file from [" + mapping_infile + "] ["
+ + e.getMessage() + "]" );
+ }
+ if ( ForesterUtil.isEmpty( seqs ) ) {
+ ForesterUtil.fatalError( decorator.PRG_NAME, "fasta-file [" + mapping_infile
+ + "] is devoid of fasta-formatted sequences" );
+ }
+ final Map<String, String> map = new HashMap<String, String>();
+ for( final MolecularSequence seq : seqs ) {
+ if ( ForesterUtil.isEmpty( seq.getIdentifier() ) ) {
+ ForesterUtil.fatalError( decorator.PRG_NAME, "fasta-file [" + mapping_infile
+ + "] contains sequence with empty identifier" );
+ }
+ if ( map.containsKey( seq.getIdentifier() ) ) {
+ ForesterUtil.fatalError( decorator.PRG_NAME, "sequence identifier [" + seq.getIdentifier()
+ + "] is not unique" );
+ }
+ if ( seq.getLength() < 1 ) {
+ ForesterUtil.fatalError( decorator.PRG_NAME, "sequence [" + seq.getIdentifier() + "] is empty" );
+ }
+ map.put( seq.getIdentifier(), seq.getMolecularSequenceAsString() );
+ if ( verbose ) {
+ System.out.println( seq.getIdentifier() + " => " + seq.getMolecularSequenceAsString() );
+ }
+ }
+ return map;
+ }
+
+ private static void argumentsError() {
+ System.out.println();
+ System.out.println( decorator.PRG_NAME + " -" + ADVANCED_TABLE_OPTION + " | -f=<c> <phylogenies infile> "
+ + "<mapping table file|fasta-file> <phylogenies outfile>" );
+ System.out.println();
+ System.out.println( "options:" );
+ System.out.println();
+ System.out.println( " -" + ADVANCED_TABLE_OPTION + " : table instead of one to one map (-f=<c>)" );
+ System.out.println( " -p : picky, fails if node name not found in mapping table" );
+ System.out.println( " -" + TREE_NAME_OPTION + "=<s>: name for the phylogeny" );
+ System.out.println( " -" + TREE_ID_OPTION + "=<s>: identifier for the phylogeny (in the form provider:value)" );
+ System.out.println( " -" + TREE_DESC_OPTION + "=<s>: description for phylogenies" );
+ System.out.println();
+ System.out.println();
+ System.out.println( "advanced options, only available if -" + ADVANCED_TABLE_OPTION + " is not used:" );
+ System.out.println();
+ System.out.println( " -f=<c> : field to be replaced: " + NODE_NAME_FIELD + " : node name" );
+ System.out.println( " " + SEQUENCE_ANNOTATION_DESC
+ + " : sequence annotation description" );
+ System.out.println( " " + DS_FILED + " : domain structure" );
+ System.out.println( " " + TAXONOMY_CODE_FIELD + " : taxonomy code" );
+ System.out.println( " " + TAXONOMY_SCIENTIFIC_NAME_FIELD
+ + ": taxonomy scientific name" );
+ System.out.println( " " + SEQUENCE_NAME_FIELD + " : sequence name" );
+ System.out.println( " " + MOL_SEQ + " : molecular sequence" );
+ System.out.println( " -k=<n> : key column in mapping table (0 based)," );
+ System.out.println( " names of the node to be decorated - default is 0" );
+ System.out.println( " -v=<n> : value column in mapping table (0 based)," );
+ System.out.println( " data which with to decorate - default is 1" );
+ System.out.println( " -" + EXTRACT_BRACKETED_SCIENTIC_NAME_OPTION
+ + " : to extract bracketed scientific names, e.g. [Nematostella vectensis]" );
+ System.out.println( " -" + EXTRACT_BRACKETED_TAXONOMIC_CODE_OPTION
+ + " : to extract bracketed taxonomic codes, e.g. [NEMVE]" );
+ System.out.println( " -s=<c> : column separator in mapping file, default is tab" );
+ System.out.println( " -c : cut name after first space (only for -f=n)" );
+ System.out.println( " -" + decorator.TRIM_AFTER_TILDE_OPTION
+ + " : trim node name to be replaced after tilde" );
+ System.out.println( " -" + decorator.MIDPOINT_ROOT_OPTION + " : to midpoint-root the tree" );
+ System.out.println( " -" + decorator.ORDER_TREE_OPTION + " : to order tree branches" );
+ System.out.println( " -" + decorator.VERBOSE_OPTION + " : verbose" );
+ System.out.println();
+ System.exit( -1 );
+ }