// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.io.parsers;
import org.forester.msa.Msa;
import org.forester.msa.MsaFormatException;
import org.forester.sequence.BasicSequence;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
public class FastaParser {
private static final Pattern ANYTHING_REGEX = Pattern.compile( "[\\d\\s]+" );
//>gi|71834668|ref|NP_001025424.1| Bcl2 [Danio rerio]
public static final Pattern FASTA_DESC_LINE = Pattern
- .compile( ">?\\s*([^|]+)\\|([^|]+)\\S*\\s+(.+)\\s+\\[(.+)\\]" );
+ .compile( ">?\\s*([^|]+)\\|([^|]+)\\S*\\s+(.+)\\s+\\[(.+)\\]" );
public static void main( final String[] args ) {
final String a = ">gi|71834668|ref|NP_001025424.1| Bcl2 [Danio rerio]";
}
}
+ static public boolean isLikelyFasta( final File f ) throws IOException {
+ return isLikelyFasta( new FileInputStream( f ) );
+ }
+
static public boolean isLikelyFasta( final InputStream is ) throws IOException {
final BufferedReader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) );
String line = null;
return parseMsa( new ByteArrayInputStream( bytes ) );
}
- static public List<Sequence> parse( final File f ) throws IOException {
+ static public List<MolecularSequence> parse( final File f ) throws IOException {
return parse( new FileInputStream( f ) );
}
- static public List<Sequence> parse( final InputStream is ) throws IOException {
+ static public List<MolecularSequence> parse( final InputStream is ) throws IOException {
final BufferedReader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) );
String line = null;
int line_counter = 0;
}
addSeq( name, current_seq, temp_msa );
reader.close();
- final List<Sequence> seqs = new ArrayList<Sequence>();
+ final List<MolecularSequence> seqs = new ArrayList<MolecularSequence>();
for( int i = 0; i < temp_msa.size(); ++i ) {
seqs.add( BasicSequence.createAaSequence( temp_msa.get( i )[ 0 ].toString(),
temp_msa.get( i )[ 1 ].toString() ) );