<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biojava3.core.sequence;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.LinkedHashMap;

import org.biojava3.core.sequence.compound.AminoAcidCompound;
import org.biojava3.core.sequence.compound.AminoAcidCompoundSet;
import org.biojava3.core.sequence.compound.DNACompoundSet;
import org.biojava3.core.sequence.compound.NucleotideCompound;
import org.biojava3.core.sequence.io.DNASequenceCreator;
import org.biojava3.core.sequence.io.FastaReader;
import org.biojava3.core.sequence.io.GenericFastaHeaderParser;
import org.biojava3.core.sequence.io.ProteinSequenceCreator;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class FastaReaderHelper {

  /**
   * Read a fasta file containing amino acids with setup that would handle most
   * cases.
   *
   * @param file
   * @return
   * @throws Exception
   */
    public static LinkedHashMap<String,ProteinSequence> readFastaProteinSequence(File file) throws Exception {
        FileInputStream inStream = new FileInputStream(file);
        LinkedHashMap<String,ProteinSequence> proteinSequences = readFastaProteinSequence(inStream);
        inStream.close();
        return proteinSequences;
    }

  /**
   * Read a fasta file containing amino acids with setup that would handle most
   * cases. User is responsible for closing InputStream because you opened it
   *
   * @param inStream
   * @return
   * @throws Exception
   */
    public static LinkedHashMap<String,ProteinSequence> readFastaProteinSequence(InputStream inStream) throws Exception {
        FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
        return fastaReader.process();
    }

    public static LinkedHashMap<String,DNASequence> readFastaDNASequence(InputStream inStream) throws Exception {
        FastaReader<DNASequence,NucleotideCompound> fastaReader = new FastaReader<DNASequence,NucleotideCompound>(inStream, new GenericFastaHeaderParser(), new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()));
        return fastaReader.process();
    }

    public static LinkedHashMap<String,DNASequence> readFastaDNASequence(File file) throws Exception {
        FileInputStream inStream = new FileInputStream(file);
        LinkedHashMap<String,DNASequence> dnaSequences = readFastaDNASequence(inStream);
        inStream.close();
        return dnaSequences;
    }


   public static void main(String args[]) throws Exception {

        FastaReaderHelper.readFastaDNASequence(new File("/Users/Scooter/scripps/dyadic/analysis/454Scaffolds/454Scaffolds.fna"));
   }
}
<commit_msg>Adding the generics to the reader main example<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biojava3.core.sequence;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.LinkedHashMap;

import org.biojava3.core.sequence.compound.AminoAcidCompound;
import org.biojava3.core.sequence.compound.AminoAcidCompoundSet;
import org.biojava3.core.sequence.compound.DNACompoundSet;
import org.biojava3.core.sequence.compound.NucleotideCompound;
import org.biojava3.core.sequence.io.DNASequenceCreator;
import org.biojava3.core.sequence.io.FastaReader;
import org.biojava3.core.sequence.io.GenericFastaHeaderParser;
import org.biojava3.core.sequence.io.ProteinSequenceCreator;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class FastaReaderHelper {

  /**
   * Read a fasta file containing amino acids with setup that would handle most
   * cases.
   *
   * @param file
   * @return
   * @throws Exception
   */
    public static LinkedHashMap<String,ProteinSequence> readFastaProteinSequence(File file) throws Exception {
        FileInputStream inStream = new FileInputStream(file);
        LinkedHashMap<String,ProteinSequence> proteinSequences = readFastaProteinSequence(inStream);
        inStream.close();
        return proteinSequences;
    }

  /**
   * Read a fasta file containing amino acids with setup that would handle most
   * cases. User is responsible for closing InputStream because you opened it
   *
   * @param inStream
   * @return
   * @throws Exception
   */
    public static LinkedHashMap<String,ProteinSequence> readFastaProteinSequence(InputStream inStream) throws Exception {
        FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(inStream, new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
        return fastaReader.process();
    }

    public static LinkedHashMap<String,DNASequence> readFastaDNASequence(InputStream inStream) throws Exception {
        FastaReader<DNASequence,NucleotideCompound> fastaReader = new FastaReader<DNASequence,NucleotideCompound>(inStream, new GenericFastaHeaderParser<DNASequence, NucleotideCompound>(), new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()));
        return fastaReader.process();
    }

    public static LinkedHashMap<String,DNASequence> readFastaDNASequence(File file) throws Exception {
        FileInputStream inStream = new FileInputStream(file);
        LinkedHashMap<String,DNASequence> dnaSequences = readFastaDNASequence(inStream);
        inStream.close();
        return dnaSequences;
    }


   public static void main(String args[]) throws Exception {

        FastaReaderHelper.readFastaDNASequence(new File("/Users/Scooter/scripps/dyadic/analysis/454Scaffolds/454Scaffolds.fna"));
   }
}

{'fraction_non_alphanumeric': 0.08679245283018867, 'fraction_numerical': 0.005145797598627788, 'mean_word_length': 4.831, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6543823', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1642, 'n_words': 353}