/** * Reads the file {@code fastaFile}, expecting exactly two sequences which give a pairwise * alignment. Uses this and two structures to create an AFPChain corresponding to the alignment. * Uses a {@link CasePreservingProteinSequenceCreator} and assumes that a residue is aligned if * and only if it is given by an uppercase letter. * * @see #fastaToAfpChain(ProteinSequence, ProteinSequence, Structure, Structure) * @throws IOException * @throws StructureException */ public static AFPChain fastaFileToAfpChain( File fastaFile, Structure structure1, Structure structure2) throws IOException, StructureException { InputStream inStream = new FileInputStream(fastaFile); SequenceCreatorInterface<AminoAcidCompound> creator = new CasePreservingProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()); SequenceHeaderParserInterface<ProteinSequence, AminoAcidCompound> headerParser = new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(); FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(inStream, headerParser, creator); LinkedHashMap<String, ProteinSequence> sequences = fastaReader.process(); inStream.close(); return fastaToAfpChain(sequences, structure1, structure2); }
/** * Takes a structure and sequence corresponding to an alignment between a structure or sequence * and itself (or even a structure with a sequence), where the result has a circular permutation * site {@link cpSite} residues to the right. * * @param fastaFile A FASTA file containing exactly 2 sequences, the first unpermuted and the * second permuted * @param cpSite The number of residues from the beginning of the sequence at which the circular * permutation site occurs; can be positive or negative; values greater than the length of the * sequence are acceptable * @throws IOException * @throws StructureException */ public static AFPChain cpFastaToAfpChain(File fastaFile, Structure structure, int cpSite) throws IOException, StructureException { InputStream inStream = new FileInputStream(fastaFile); SequenceCreatorInterface<AminoAcidCompound> creator = new CasePreservingProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()); SequenceHeaderParserInterface<ProteinSequence, AminoAcidCompound> headerParser = new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(); FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(inStream, headerParser, creator); LinkedHashMap<String, ProteinSequence> sequences = fastaReader.process(); inStream.close(); Iterator<ProteinSequence> iter = sequences.values().iterator(); ProteinSequence first = iter.next(); ProteinSequence second = iter.next(); return cpFastaToAfpChain(first, second, structure, cpSite); }