/*
 * The Gemma project
 * 
 * Copyright (c) 2006 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ubic.gemma.loader.genome;

import java.io.InputStream;
import java.util.Collection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import ubic.gemma.model.genome.biosequence.BioSequence;

import junit.framework.TestCase;

/**
 * @author pavlidis
 * @version $Id$
 */
public class FastaParserTest extends TestCase {

    private static Log log = LogFactory.getLog( FastaParserTest.class.getName() );
    InputStream f;

    protected void setUp() throws Exception {
        super.setUp();
        f = FastaParserTest.class.getResourceAsStream( "/data/loader/genome/testsequence.fa" );
    }

    public void testParseInputStream() throws Exception {
        FastaParser p = new FastaParser();
        p.parse( f );
        Collection<BioSequence> actualResult = p.getResults();
        assertTrue( actualResult != null );
        assertEquals( 2, actualResult.size() );
        assertTrue( actualResult.iterator().next() instanceof BioSequence );
        for ( Object object : actualResult ) {
            BioSequence b = ( BioSequence ) object;
            log.debug( "NAME=" + b.getName() + " DESC=" + b.getDescription() + " SEQ=" + b.getSequence() );
        }
    }

}

@@ -1107,16 +1107,35 @@
 tream f;
+%0A    InputStream g;
 %0A%0A    pr
@@ -1292,16 +1292,113 @@
 e.fa%22 );
+%0A%0A        g = FastaParserTest.class.getResourceAsStream( %22/data/loader/genome/testsequence.fa%22 );
 %0A    %7D%0A%0A
@@ -1679,85 +1679,8 @@
  );%0A
-        assertTrue( actualResult.iterator().next() instanceof BioSequence );%0A
     
@@ -1899,10 +1899,908 @@
 %0A    %7D%0A%0A
+    public void testParseInputStreamAffyTarget() throws Exception %7B%0A        FastaParser p = new FastaParser();%0A        p.parse( g );%0A        Collection%3CBioSequence%3E actualResult = p.getResults();%0A        assertTrue( actualResult != null );%0A        assertEquals( 2, actualResult.size() );%0A        for ( Object object : actualResult ) %7B%0A            BioSequence b = ( BioSequence ) object;%0A%0A            assertTrue( b.getSequenceDatabaseEntry() != null%0A                    && b.getSequenceDatabaseEntry().getExternalDatabase() != null%0A                    && b.getSequenceDatabaseEntry().getExternalDatabase().getName().equalsIgnoreCase( %22genbank%22 ) );%0A%0A            if ( log.isDebugEnabled() )%0A                log.debug( %22NAME=%22 + b.getName() + %22 DESC=%22 + b.getDescription() + %22 SEQ=%22 + b.getSequence() + %22 GB=%22%0A                        + b.getSequenceDatabaseEntry().getAccession() );%0A%0A        %7D%0A    %7D%0A%0A
 %7D%0A

test updates