001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022package org.biojava.bio.seq.io; 023 024import java.io.Serializable; 025import java.util.StringTokenizer; 026 027/** 028 * Simple filter which performs a default extraction of data from 029 * the description lines of FASTA files. Behaviour is similar 030 * to DefaultDescriptionReader in the old I/O framework. 031 * 032 * @author Thomas Down 033 * @since 1.1 034 * @deprecated Use org.biojavax.bio.seq.io.FastaFormat 035 */ 036 037public class FastaDescriptionLineParser extends SequenceBuilderFilter { 038 /** 039 * Factory which wraps SequenceBuilders in a FastaDescriptionLineParser 040 * 041 * @author Thomas Down 042 */ 043 044 public static class Factory implements SequenceBuilderFactory, Serializable { 045 private SequenceBuilderFactory delegateFactory; 046 047 public Factory(SequenceBuilderFactory delegateFactory) { 048 this.delegateFactory = delegateFactory; 049 } 050 051 public SequenceBuilder makeSequenceBuilder() { 052 return new FastaDescriptionLineParser(delegateFactory.makeSequenceBuilder()); 053 } 054 } 055 056 public FastaDescriptionLineParser(SequenceBuilder delegate) { 057 super(delegate); 058 } 059 060 public void addSequenceProperty(Object key, Object value) throws ParseException { 061 getDelegate().addSequenceProperty(key, value); 062 063 if (FastaFormat.PROPERTY_DESCRIPTIONLINE.equals(key)) { 064 String dline = value.toString(); 065 StringTokenizer toke = new StringTokenizer(dline); 066 String name = toke.nextToken(); 067 setName(name); 068 setURI("urn:sequence/fasta:" + name); 069 if (toke.hasMoreTokens()) { 070 getDelegate().addSequenceProperty("description", toke.nextToken("******")); 071 } 072 } 073 } 074}