This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to calculate elment compostion of fasta protein file using biojava?

how to calculate elment compostion of fasta protein file using biojava?

sequence

I want atomic composition not amino acid composition

1 answer

I'm not a Java programmer (I use its close cousin C#), but here's the step-by-step that you just need to translate into code:

1. Create a Map<string, int>variable to store the distinct elements and their associated counts.

2. Examine the structure of the AminoAcidComposition.xml file. Each <aminoacid> node has a schema akin to the following:

<aminoacid name="Alanine" shortname="Ala" symbol="A">
        <elements count="3" name="Carbon"/>
        <elements count="1" name="Nitrogen"/>
        <elements count="1" name="Oxygen"/>
        <isotopes count="5" name="Hydrogen"/>
</aminoacid>

3. Use the symbol attribute to identify the correct <aminoacid> node to use for each character in the FASTA sequence. Then cycle through the <elements> nodes, using the name attribute of the node as the key to your Map<string, int> variable, incrementing the value for that key by the value of the countattribute, which you'll probably need to coerce to an int since Java is strongly-typed.

Log in to answer this question.