git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
needed for https for treebase
[jalview.git]
/
forester
/
java
/
src
/
org
/
forester
/
application
/
fasta_split.java
diff --git
a/forester/java/src/org/forester/application/fasta_split.java
b/forester/java/src/org/forester/application/fasta_split.java
index
544701a
..
16999c7
100644
(file)
--- a/
forester/java/src/org/forester/application/fasta_split.java
+++ b/
forester/java/src/org/forester/application/fasta_split.java
@@
-25,7
+25,7
@@
//
//
// "java -Xmx1024m -cp path\to\forester.jar org.forester.application.fasta_split
//
//
// "java -Xmx1024m -cp path\to\forester.jar org.forester.application.fasta_split
-//
+//
//
package org.forester.application;
//
package org.forester.application;
@@
-51,7
+51,7
@@
public final class fasta_split {
final static private String PRG_NAME = "fasta_split";
final static private String PRG_VERSION = "1.00";
final static private String PRG_NAME = "fasta_split";
final static private String PRG_VERSION = "1.00";
- final static private String PRG_DATE = "150325";
+ final static private String PRG_DATE = "150331";
public static void main( final String args[] ) {
ForesterUtil.printProgramInformation( fasta_split.PRG_NAME, fasta_split.PRG_VERSION, fasta_split.PRG_DATE );
public static void main( final String args[] ) {
ForesterUtil.printProgramInformation( fasta_split.PRG_NAME, fasta_split.PRG_VERSION, fasta_split.PRG_DATE );
@@
-80,6
+80,9
@@
public final class fasta_split {
if ( !ForesterUtil.isEmpty( error ) ) {
ForesterUtil.fatalError( PRG_NAME, error );
}
if ( !ForesterUtil.isEmpty( error ) ) {
ForesterUtil.fatalError( PRG_NAME, error );
}
+ if ( !outdir.exists() ) {
+ new File( outdir.toString() ).mkdir();
+ }
if ( !outdir.isDirectory() ) {
ForesterUtil.fatalError( PRG_NAME, outdir + " is not a directory" );
}
if ( !outdir.isDirectory() ) {
ForesterUtil.fatalError( PRG_NAME, outdir + " is not a directory" );
}
@@
-93,10
+96,11
@@
public final class fasta_split {
if ( ( seqs == null ) || seqs.isEmpty() ) {
ForesterUtil.fatalError( PRG_NAME, infile + " appears empty" );
}
if ( ( seqs == null ) || seqs.isEmpty() ) {
ForesterUtil.fatalError( PRG_NAME, infile + " appears empty" );
}
+ System.out.println( "Read " + seqs.size() + " sequences" );
final Map<String, List<MolecularSequence>> output = new HashMap<String, List<MolecularSequence>>();
int cc = 0;
for( final MolecularSequence seq : seqs ) {
final Map<String, List<MolecularSequence>> output = new HashMap<String, List<MolecularSequence>>();
int cc = 0;
for( final MolecularSequence seq : seqs ) {
- System.out.println( ++cc );
+ ++cc;
final Matcher m = pa.matcher( seq.getIdentifier() );
if ( m.find() ) {
final String key = m.group( 1 );
final Matcher m = pa.matcher( seq.getIdentifier() );
if ( m.find() ) {
final String key = m.group( 1 );
@@
-106,8
+110,8
@@
public final class fasta_split {
output.get( key ).add( seq );
}
else {
output.get( key ).add( seq );
}
else {
- //ForesterUtil.fatalError( PRG_NAME, pattern_str + " not found in sequence \"" + seq.getIdentifier() + "\"" );
- System.out.println( "warning: " + pattern_str + " not found in sequence \"" + seq.getIdentifier() + "\"" );
+ System.out.println( "warning: " + pattern_str + " not found in sequence \"" + seq.getIdentifier()
+ + "\"" );
final String key = "unknown";
if ( !output.containsKey( key ) ) {
output.put( key, new ArrayList<MolecularSequence>() );
final String key = "unknown";
if ( !output.containsKey( key ) ) {
output.put( key, new ArrayList<MolecularSequence>() );
@@
-117,11
+121,13
@@
public final class fasta_split {
}
int c = 0;
for( final Map.Entry<String, List<MolecularSequence>> entry : output.entrySet() ) {
}
int c = 0;
for( final Map.Entry<String, List<MolecularSequence>> entry : output.entrySet() ) {
- final File of = new File( outdir.getAbsolutePath().toString() + "/" + entry.getKey() + ".fasta" );
+ String s = entry.getKey();
+ s = s.replace( '*', '_' );
+ final File of = new File( outdir.getAbsolutePath().toString() + "/" + s + ".fasta" );
if ( of.exists() ) {
ForesterUtil.fatalError( PRG_NAME, of + " already exists" );
}
if ( of.exists() ) {
ForesterUtil.fatalError( PRG_NAME, of + " already exists" );
}
- System.out.println( ++c + ": writing " + of );
+ System.out.println( ++c + ": writing " + of + " [" + entry.getValue().size() + " seqs]" );
try {
SequenceWriter.writeSeqs( entry.getValue(), of, SEQ_FORMAT.FASTA, 60 );
}
try {
SequenceWriter.writeSeqs( entry.getValue(), of, SEQ_FORMAT.FASTA, 60 );
}
@@
-133,6
+139,7
@@
public final class fasta_split {
private static void argumentsError() {
System.out.println( PRG_NAME + " <pattern> <infile> <outdir>" );
private static void argumentsError() {
System.out.println( PRG_NAME + " <pattern> <infile> <outdir>" );
+ System.out.println( "Example: " + PRG_NAME + " \"v-germ=(\\S+)\" tt.fasta outdir" );
System.out.println();
System.exit( -1 );
}
System.out.println();
System.exit( -1 );
}