for loop command
1
0
Entering edit mode
3.8 years ago
harry ▴ 40

I have fasta sequence and I want to write a script for "for loop" command:-

>ENST00000014935::X:154401758-154402841
TAGGTTTTTAATTACCTTTATTTTATTTTGCCAAACATACCTGGGAATACCTTTTATTTTTTTTTTACCTTGGGGTGATGGTTCCAAACCATAAATGTGATTATAGTTAACACATGACCCTTCTAGCGTCCCAGCCAGTGTTTTTCCTGACCTCTCTTCTTTGGAGAGGAGGATGGAAGGGAGGGGTCCGGCATGCTGCTGGCATTTTGCTGTGTCCTGCAGCCCCTTTCCGGGACACCTGGGTTCACACAGCTTTTTAGCTTACATAACTGGTGCAGATTTTCTGTGTGGAGATGTTGCCTTGACCAGCCTTGGCTGGACTTTACCAGGCATGCAGAAGCCTGTACCAACACAGACTACAGCACCCAGGAGGTGCGAGTGTGGCTGCTCAGCGGTTATAACAGGCCTGACTGCATTGTTCACCGGATTATAATGAGCCAAAATGTTTCCCGGTGTTTGCTGGTTTCAGGGAAGGAGTTTGATATAGCAGATTAACCACCCTCCTTGTAGCTATTGGGGCTTAATGGTTTCCTGGTGATTCTTACCAATCCACAATAAACATGGCCCATTGGCATATCTGCTGCACAAGTGTCCTATCTCACCAATCTGGGTTTTTGTTCTCAGTAACTTTCCTTCTTGTCATACAACATCTTCATTCCTCTTTCTGAACCCTCCCTTCCCCTACCCCAACCCAGAGCCCACTTTGTCTCCACTCCTGATACTACACTACCTGGCAGGTGGCATGAGTGCAGGGCCCCTGGCTTCCTCTCCTAATCTAGGCACAAGCCCAACCAAAGAACAAGAGCCAAATCAAACAAGGCAGGCAGGGGTGGACTACAGTCACAGGGCAACTATAGTTGAAGCCCCCCAGCCCCAGGGCTGGATGGACGGGGGAGGCTGGGGTTTAAGTCCCAAAAGGCAGCAGGCCCTGGGGGGGTAGGGGGACGCTCAGGCAGCAGGGCACAGCTGAGGGGACAGGAGTGATAGCAGCAACAGAACAGTGAGGCTGAGAGGCTGGACGCTGTGCGCCTGGCTCAGCTTCAGCTCCACCTCCACGGGGTAGTGGTCACTGATGTTGAGGGC
>ENST00000014935::X:154402942-154403190
TCCTCCTCGGTGAGCTGGAAGCTCGTGGGGAAGTCAAAGGCAGCCGCAGTGTGCAGCAGACTCCGGCAGCGCTCCCCGTGCAGCACGACGCGGTCATAGGTGCAGTGGGTGCTGGCCCGCACTGTGGTGTCCTCCCCATCGGCAATCACCCAGTGGAAGCCTGGCTCAGTCCGCAGCTCCAGCTTGTCCAGGCGCTTTTTGGTCAGTGAAGCGCAGTCAGCATTGAAGTCCCCAAGCAGGATCACGTC
>ENST00000014935::X:154403269-154403381
TTGCTCTGCCAGTGCTGGGAGACCTCCAGAAACACATCGTAGAGGGCGTTCAGCTCCTTCTCTACGGCCTTAGGAGTGGTGTGCAGCGGGACCAACACCAGGCTGGGAAGGA
>ENST00000014935::X:154403522-154403622
ATTGCTGGGCAAAGAGAACTGGGCCACAAATGGCTCCCGGGCAAAGACGTCATCCTCATCGTTGTACACGTAGGAACTCAGGACCTGTGTTTTGTGTGAC
>ENST00000014935::X:154404828-154404914
GATAGAAGTACACATACGTCTCCATGTAGGTGCTGCGCCCCAGCTGGGGGCTGCTCAGGGTGCTGTAGGGCCCAGAGCCATCAAAT
>ENST00000055335::X:49269793-49270873
TTGGCTGCCCGCCCCTTCAGGCCCTGCCCCCGCCGGTCCCGCCGCCGGTGCCGTCGGTGCCGCCGCCGCCGCCGATATGGCGCGTACGGCCCCTGTGGAGCCCCCGCTGCGGCATTCCGCGCCCCCCTCGCCGGCCGCGGGTGAGCCCCGCACCTCGGTCGAGGCGGCGGTGGCCCCGCGGAGGGTGCTGTTCGCCGACGAGGCCTTGGGGCTGCCGCTGGCGCAGTTGCGCCGCTACCGGCCGTGGGGCGGGCCCGGGGCGGGCAAGATGGCGGCGGCGGCCGGGCAAGATGGCGGCGGCGGCGGCGGGGCCGACGAGGACGACGATGGCGAGGATGGGGATGAAGGGGAGGAGGAAGAGGAGGCTTGCCCCGAGCCCTCACCGCTGTGCCCCGTCCCCGCTGGCGGGGGGTTTTACCTGGTCCCCACATTTTCGCTGCCGCCCGCGCCGGGCCGTCTGGAGCGCTTGGGGCGCGTCATGGTGGAGCTGGAGGCGCTGCTGCCGCCTCCCGGAGCGGTCCCCGGGGGTGCCGGGGTGTGGGTGCCTGGGGGCCGCCCGCCGGTGCTGCGCGGGTTGGTACGCGTGCTGAACCGCTCCTTCGAGAAGGCGGTGCACGTGCGGGCCTCACACGACGGCTGGGCTTCCTTTTGCGACCACCCAGCGCGCTACGTCCCGCGCAGCCCGCCGTGGGCAGGAGCGGGAGGAACAGGAGCAGGAGATCCCATCCTGGATCCGGGGCTCGGCCTGGGTCCCGGCCAGGCATCCGCCTCCTCGCCCGACGACGGCGGCCGCACCGACCGCTTTGCCTTCCAGCTGCCCTTTGCTGAGGGCGCGGGCGATGGGGCGCGCCTCGACTTCGTGGTGCGCTATGAGACCCCTGAGGGCACTTTCTGGGCCAACAACCACGGCCGCAACTACACAGTCCTGCTCCGGATCGCACCCGCTCCCACACCCACTGATGCCGAAGGGCTGCCCCAGCAGCAGCAGCTGCCGCAGCTGGAGCCACAGCCCGAGTGCCAGGGTCCCGTGGAGGCTGAGGCCAGGCAGCTGAAGAGCTGCATGAAGCCGGTGAGGCGCAG
>ENST00000055335::X:49281406-49281461
CCTGCCGAGGAGGAACTGAAGACGAAGAACATGGATGATAACACCTTTGCCATGG
>ENST00000055335::X:49281981-49282063
AGAGCATCCTGATGTCCAGGAGTCAGTGGGTCCACTGGTAGCCCCCACCCCTCTCCGTCCATGGCCCCAGATGACACTTCAG
>ENST00000055335::X:49285834-49288090
TTTCTGACGTTCCGATGACTGGCAACCCCGCAGAAGAAGGTGATGTCCCCAGAAGCAGTCCACCTGTGGCTTTTACAGAGGTCCTCCAGGCACCGGCCATCAGGATTCCCCCCTCCTCCCCTCTCTGTGGCCTGGGTGGCTCCCCCAGAGACCAGGCCTCAGGGCCCGATGCGAGCGAGGGGGCCACCGGGCCTTTCCTGGAGCCCAGTCAGCAGCAGGCAGAGGC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GCTTCTGAGAATGCTCAACTGAAAGAGAGGCCTTCTCATCCCCAAGCTCTCCAGTCAACACAGGGCTCCCTGTGGTGACACCAGTGGAGATGAGGGAACGGGTAGATGGTGTGAGTGAGGGGAACTTTTAGAGTGGAACTGGGCATGTCCTCCGCCTACCCCCCGAGCCTGTATTTATTTTTGTATAATTCTCTGGATGAGGGAGAGTGGTCGTGAGCTGGTCTTGGGGCACAATTACCCAGAGATATATTTATTAACAGCCAACCTGTGCAACCTGCTGGAGCTTTATTTTTAATTTAATTTATATAGAGTACCTATTATTATATGCCACAATAGAGCTCTATGAGAAACAGTGTCTTGCGGTGTAGTGTTCTCCTGTTTGGGCATGAGTGTGCAGGGTGGTCACTTTCTGTGGGAGGATCACAGTGGGGAGTTGGGGGTGGGACGTGGTCGCCTGCTGCTGCTTCAACATGTCTTTCCTTGAAGATGTGTGTCTCCTCGTCTCGTGGTCCTAATCCATATGGTTCTTTGTCTTTTCCACATTCTGCCTGTGGGACCCTACAGGTGTGTATTTGGATGGTGGTGGTGGGAGCCAGGGAGGAAGAGTGGCAGCCACATGAGGGTTTGGTGTCAGTCACATGGTTGCAGTGGTAGCTGTGGTCTCCTGTGGATGTGGGGACATCAGTTGTGAATCAGCCACAAGGTTTTGAGGTTACTGAAAAAACAGCCTTTGACACCAGCAGGGAGACCCCTTAGTCCCTGAGATAAGGAAGGCCTCAGAAAGGAAAGAGGAGTTAATGTACTGCAGTACTTGGTAGCACAGTTGCTGTCCACAGACATCACATTTCTACTAAAAACAGGAAGCCCAGAAGCTTTGAAAGAAAGATATATATTTATTGCATGCAAATAAAAAACTGCTCAACAAAA

So after for loop command the Same transcript id only take as name and there respective sequence not take other transcript id. Like wise i want for my whole file. Example:--

var exons=[
    {"name":"transcript1","seq":"AATCTGATGCTA"},
    {"name":"transcript2","seq":"TCTGATGCTACC"},
    {"name":"transcript3","seq":"CATGCTG"},
    {"name":"transcript4","seq":"CCC"},
    {"name":"transcript5","seq":"CATGCCCCTG"}
    ];

My file which I want after for loop command

var exons=[
    {"name":"ENST00000055335::X:49269793-49270873","seq":"TTGGCTGCCCGCCCCTTCAGGCCCTGCCCCCGCCGGTCCCGCCGCCGGTGCCGTCGGTGCCGCCGCCGCCGCCGATATGGCGCGTACGGCCCCTGTGGAGCCCCCGCTGCGGCATTCCGCGCCCCCCTCGCCGGCCGCGGGTGAGCCCCGCACCTCGGTCGAGGCGGCGGTGGCCCCGCGGAGGGTGCTGTTCGCCGACGAGGCCTTGGGGCTGCCGCTGGCGCAGTTGCGCCGCTACCGGCCGTGGGGCGGGCCCGGGGCGGGCAAGATGGCGGCGGCGGCCGGGCAAGATGGCGGCGGCGGCGGCGGGGCCGACGAGGACGACGATGGCGAGGATGGGGATGAAGGGGAGGAGGAAGAGGAGGCTTGCCCCGAGCCCTCACCGCTGTGCCCCGTCCCCGCTGGCGGGGGGTTTTACCTGGTCCCCACATTTTCGCTGCCGCCCGCGCCGGGCCGTCTGGAGCGCTTGGGGCGCGTCATGGTGGAGCTGGAGGCGCTGCTGCCGCCTCCCGGAGCGGTCCCCGGGGGTGCCGGGGTGTGGGTGCCTGGGGGCCGCCCGCCGGTGCTGCGCGGGTTGGTACGCGTGCTGAACCGCTCCTTCGAGAAGGCGGTGCACGTGCGGGCCTCACACGACGGCTGGGCTTCCTTTTGCGACCACCCAGCGCGCTACGTCCCGCGCAGCCCGCCGTGGGCAGGAGCGGGAGGAACAGGAGCAGGAGATCCCATCCTGGATCCGGGGCTCGGCCTGGGTCCCGGCCAGGCATCCGCCTCCTCGCCCGACGACGGCGGCCGCACCGACCGCTTTGCCTTCCAGCTGCCCTTTGCTGAGGGCGCGGGCGATGGGGCGCGCCTCGACTTCGTGGTGCGCTATGAGACCCCTGAGGGCACTTTCTGGGCCAACAACCACGGCCGCAACTACACAGTCCTGCTCCGGATCGCACCCGCTCCCACACCCACTGATGCCGAAGGGCTGCCCCAGCAGCAGCAGCTGCCGCAGCTGGAGCCACAGCCCGAGTGCCAGGGTCCCGTGGAGGCTGAGGCCAGGCAGCTGAAGAGCTGCATGAAGCCGGTGAGGCGCAG"},
    {"name":"ENST00000055335::X:49281406-49281461","seq":"CCTGCCGAGGAGGAACTGAAGACGAAGAACATGGATGATAACACCTTTGCCATGG"},
    {"name":"ENST00000055335::X:49281981-49282063","seq":"AGAGCATCCTGATGTCCAGGAGTCAGTGGGTCCACTGGTAGCCCCCACCCCTCTCCGTCCATGGCCCCAGATGACACTTCAG"},
    {"name":"ENST00000055335::X:49285834-49288090","seq":"TTTCTGACGTTCCGATGACTGGCAACCCCGCAGAAGAAGGTGATGTCCCCAGAAGCAGTCCACCTGTGGCTTTTACAGAGGTCCTCCAGGCACCGGCCATCAGGATTCCCCCCTCCTCCCCTCTCTGTGGCCTGGGTGGCTCCCCCAGAGACCAGGCCTCAGGGCCCGATGCGAGCGAGGGGGCCACCGGGCCTTTCCTGGAGCCCAGTCAGCAGCAGGCAGAGGCCACATGGGGAGTATCGAGTGAGAATGGAGGGGGGCTGGAGGCTGTGAGTGGGTCAGAGGAGCTGCTCGGTGAGGACACCATCGACCAGGAGCTGGAGCAGCTCTACCTGTCTCACCTGAGCCGCCTACGGGCTGCTGTGGCTGCGGGTGGGGCAGGGGGTGGTGGGGAGGGCTCCACAGATGGAGGGATGTCCCCCAGCCATCCCCTGGGCATACTGACGGACCGCGACCTGATCTTGAAGTGGCCTGGCCCTGAGCGGGCCCTGAACAGCGCCCTGGCTGAGGAGATCACGCTGCACTATGCCCGGCTGGGGCGTGGCGTGGAGCTCATCAAGGACACCGAAGACCCTGATGATGAAGGGGAGGGTGAAGAGGGGCTCTCTGTCACACCCTCCAGCCCAGAAGGGGACAGCCCCAAGGAATCGCCTCCAGAAATCCTCTCCGGGGCCCGTTCTGTGGTAGCCACGATGGGAGATGTGTGGCTCCCATGGGCAGAGGGCTCAGGATGTGACGGCCCTGTGGTTCTGGGTACAGAGGGTCAGTTCATTGGGGATCCTGAGAAAGGGATGGGCAAGGACACCAGCTCTTTGCACATGAATAGGGTGATAGCTG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GGGTTTGGTGTCAGTCACATGGTTGCAGTGGTAGCTGTGGTCTCCTGTGGATGTGGGGACATCAGTTGTGAATCAGCCACAAGGTTTTGAGGTTACTGAAAAAACAGCCTTTGACACCAGCAGGGAGACCCCTTAGTCCCTGAGATAAGGAAGGCCTCAGAAAGGAAAGAGGAGTTAATGTACTGCAGTACTTGGTAGCACAGTTGCTGTCCACAGACATCACATTTCTACTAAAAACAGGAAGCCCAGAAGCTTTGAAAGAAAGATATATATTTATTGCATGCAAATAAAAAACTGCTCAACAAAA"},
    ];

So anyone tell me how to write forloop command for my whole file. Thanks in advance

for loop fasta • 1.1k views
ADD COMMENT
0
Entering edit mode

This question needs to be much clearer.

On what basis are you selecting ENST00000055335 and not ENST00000014935? Representing the fasta file as the dictionary format you want is easy enough, but you haven't explained how your desired output relates to the input.

I've added code formatting to your post this time, but please use the button above the writing box that looks like a 101010 in future.

ADD REPLY
0
Entering edit mode

No, I want to select all the transcripts one by one in a loop present in my file. This is the whole command for which i want to write for loop command:- So as I have different types of sequences in my fasta file. So which have same transcript id I want to select it and put it in the below commad like some transcript have 4 sequence and some have 5 sequence so all are consdiered it during for loop command :-- This is the whole command for which i want to write for loop command:-

 var exons=[
        {"name":"transcript1","seq":"AATCTGATGCTA"},
        {"name":"transcript1","seq":"TCTGATCTGATGCTACC"},
        {"name":"transcript1","seq":"CATGCTGATCTG"},
        {"name":"transcript1","seq":"CCCTGATC"}
        ];

    function recursive(i,array) {
        if(i==exons.length) {
            if(array.length==0) return;
            var t="";
            var s="";
            for(var j in array) {
                t+=exons[array[j]].name+"|";
                s+=exons[array[j]].seq;
                }
            print(">"+t+"\n"+s);
            return;
            }

        var copy = array.slice();
        recursive(i+1,copy);
        copy = array.slice();
        copy.push(i);
        recursive(i+1,copy);
        }


    var array=[];
    recursive(0,array);

As you see this ENST00000055335 transcript id have 4 sequences and this ENST00000014935 have 5 sequenced. So I want to write for loop command to select only one transcript id at a time. As you see I have already uploaded the example .So this "var exons=" consider one transcript at a time and create all possible combinations of transcripts possible.

ADD REPLY
0
Entering edit mode

Is that VBA or something (like doing that in Excel)???

ADD REPLY
0
Entering edit mode

That code comes from an answer provided by @Pierre in: A: creating virtual library preparation of all possible exons in a gene in human

ADD REPLY
0
Entering edit mode

Oh, ok, but there is no file parsing in the example..... So op wants to add code for fasta file parsing in javascript and then join all the exons.

ADD REPLY
0
Entering edit mode

yes, I want to add code before this javascript.

    >ENST00000014935::X:154402942-154403190
    TCCTCCTCGGTGAGCTGGAAGCTCGTGGGGAAGTCAAAGGCAGCCGCAGTGTGCAGCAGACTCCGGCAGCGCTCCCCGTGCAGCACGACGCGGTCATAGGTGCAGTGGGTGCTGGCCCGCACTGTGGTGTCCTCCCCATCGGCAATCACCCAGTGGAAGCCTGGCTCAGTCCGCAGCTCCAGCTTGTCCAGGCGCTTTTTGGTCAGTGAAGCGCAGTCAGCATTGAAGTCCCCAAGCAGGATCACGTC
    >ENST00000014935::X:154403269-154403381
    TTGCTCTGCCAGTGCTGGGAGACCTCCAGAAACACATCGTAGAGGGCGTTCAGCTCCTTCTCTACGGCCTTAGGAGTGGTGTGCAGCGGGACCAACACCAGGCTGGGAAGGA
    >ENST00000014935::X:154403522-154403622
    ATTGCTGGGCAAAGAGAACTGGGCCACAAATGGCTCCCGGGCAAAGACGTCATCCTCATCGTTGTACACGTAGGAACTCAGGACCTGTGTTTTGTGTGAC
    >ENST00000014935::X:154404828-154404914
    GATAGAAGTACACATACGTCTCCATGTAGGTGCTGCGCCCCAGCTGGGGGCTGCTCAGGGTGCTGTAGGGCCCAGAGCCATCAAAT
    >ENST00000014935::X:154404995-154405083
    GATTGAGTTCTCGAAGCAGGAGCGGGATGGCGCTGCCGGAAGAGTCCACCACCTCCTGCAGCACCATGATGTCACAGCGAGCCAGTAT
    >ENST00000014935::X:154405434-154405655
    CGAACTAAGGTGTCCATCACCTGCTCCCTGGCCACCTTGGCCAGTGTCAGCCGCTGGGCATTGAAGGCGCAGATGCGAAAGGCCTGGGCCCCATTGGCCAGGATGAGGAAGAGGAGTGCAGTTGGGTAGTGCATGGCTGTGTGTGGCTGCCGGGGACACCCCAGGAATCCAGGCTGCCCCAGGGTGCGCTCTCACTGGGCTCAGTTCTGGCTCTGGAAGCG
    >ENST00000014935::X:154409112-154409196
    TGCTCAGACCAGCTTGTCACCAAGTCTGCCTCATCCTTAAGTGGATCGCGATACCCCAGAAGAGCAGCTCCTGCCTGAATAGGG
    >ENST00000014935::X:154409418-154410039
    TGTGAGTCACTCAAGCCTGGGGCAAGGAGGGGCTGGTGCCTGAGTGAGACCCCGAGCTTCGCTCGCCAGGCCCGTCGCTCAGCTCCCGGTCTGGGTCCCCAGTCAGCAGTTGCTGGGGAAGGCGCAGGAGCTGGAAGTCATGCCTGATGCCACGAGACCGGGCACCCCAAGGGCGTGAGTCTTCTGTCCCTGTTGTTGGGTTCTGAGTCCCAGTGTGGCTGCACACTTCTGAGTTAGGGGTGTTTGATGCAAGCGCTCTGGAGACCCAAAGAGAGGGACAGTCCACACATGATCTGGCCACAGTCGTGAAGTCAAGGGAGGACTGAGGATCTGCCCCAGAGAGGAGGAGACCCAGGGAGCTGGCAGTCCAACGTCCTGGGGGTCCTGCAGTAATGCTGTTGGGACAAATGAGGTGCTCGGACAGGGTCTGTGAGCAGGAGGTGGGGCTGAATCCACTCAGCTTCTCATGGGATGGCTGTAGCTAATGGATTCGACGTGGTAATAGAAGGCTGGACAAATTTTAAAAAATCAATAAATTATGGGCTGGGCGTGGTGGCTCATGCCTGTAATCCCAGCACTTTGGGAGGCTGAGGCGGGTGGATACGAGGTCAGGCGTTCAAG
    >ENST00000055335::X:49269793-49270873
    TTGGCTGCCCGCCCCTTCAGGCCCTGCCCCCGCCGGTCCCGCCGCCGGTGCCGTCGGTGCCGCCGCCGCCGCCGATATGGCGCGTACGGCCCCTGTGGAGCCCCCGCTGCGGCATTCCGCGCCCCCCTCGCCGGCCGCGGGTGAGCCCCGCACCTCGGTCGAGGCGGCGGTGGCCCCGCGGAGGGTGCTGTTCGCCGACGAGGCCTTGGGGCTGCCGCTGGCGCAGTTGCGCCGCTACCGGCCGTGGGGCGGGCCCGGGGCGGGCAAGATGGCGGCGGCGGCCGGGCAAGATGGCGGCGGCGGCGGCGGGGCCGACGAGGACGACGATGGCGAGGATGGGGATGAAGGGGAGGAGGAAGAGGAGGCTTGCCCCGAGCCCTCACCGCTGTGCCCCGTCCCCGCTGGCGGGGGGTTTTACCTGGTCCCCACATTTTCGCTGCCGCCCGCGCCGGGCCGTCTGGAGCGCTTGGGGCGCGTCATGGTGGAGCTGGAGGCGCTGCTGCCGCCTCCCGGAGCGGTCCCCGGGGGTGCCGGGGTGTGGGTGCCTGGGGGCCGCCCGCCGGTGCTGCGCGGGTTGGTACGCGTGCTGAACCGCTCCTTCGAGAAGGCGGTGCACGTGCGGGCCTCACACGACGGCTGGGCTTCCTTTTGCGACCACCCAGCGCGCTACGTCCCGCGCAGCCCGCCGTGGGCAGGAGCGGGAGGAACAGGAGCAGGAGATCCCATCCTGGATCCGGGGCTCGGCCTGGGTCCCGGCCAGGCATCCGCCTCCTCGCCCGACGACGGCGGCCGCACCGACCGCTTTGCCTTCCAGCTGCCCTTTGCTGAGGGCGCGGGCGATGGGGCGCGCCTCGACTTCGTGGTGCGCTATGAGACCCCTGAGGGCACTTTCTGGGCCAACAACCACGGCCGCAACTACACAGTCCTGCTCCGGATCGCACCCGCTCCCACACCCACTGATGCCGAAGGGCTGCCCCAGCAGCAGCAGCTGCCGCAGCTGGAGCCACAGCCCGAGTGCCAGGGTCCCGTGGAGGCTGAGGCCAGGCAGCTGAAGAGCTGCATGAAGCCGGTGAGGCGCAG
    >ENST00000055335::X:49281406-49281461
    CCTGCCGAGGAGGAACTGAAGACGAAGAACATGGATGATAACACCTTTGCCATGG
    >ENST00000055335::X:49281981-49282063
    AGAGCATCCTGATGTCCAGGAGTCAGTGGGTCCACTGGTAGCCCCCACCCCTCTCCGTCCATGGCCCCAGATGACACTTCAG

    >ENST00000039007::X:38352604-38352773
    ACACATTTCTTAGTTTTTAGGTGGCCCCCGCTGGCTAACTTGCTGTGGAGTTTTCAAGGGCATAGAATCGTCCTTTACACAATTAAAAGAAGATGCTGTTTAATCTGAGGATCCTGTTAAACAATGCAGCTTTTAGAAATGGTCACAACTTCATGGTTCGAAATTTTCG
    >ENST00000039007::X:38367291-38367429
    TGTGGACAACCACTACAAAATAAAGTGCAGCTGAAGGGCCGTGACCTTCTCACTCTAAAAAACTTTACCGGAGAAGAAATTAAATATATGCTATGGCTATCAGCAGATCTGAAATTTAGGATAAAACAGAAAGGAGAG

Here is some of my fasta sequence file and I want to add all these in the javascript and this will only possible through for loop command so anyone can help me how to write a for loop command for this javascript to get all possible exon files. I don't know how to write a for loop command for this script. Thanks in advance for your suggestions.

ADD REPLY
0
Entering edit mode

Please can anyone suggest to me how to do it. I am waiting for answers. Thanks in advance.

ADD REPLY
0
Entering edit mode

Select one transcript ID at a time and do what with it?

Your example and your desired output do not correspond, it just shows one of the exon IDs. You also need to be clear about what language you want to do this with.

In shell for example (with the exception of the latest version of bash), for the most part associative arrays (dictionaries) are not supported.

In python, you cannot have multiple dictionary entries with the same key, unless you wrap it in a list, which it looks like your code above does, but I'm not familiar with whatever that language is (I guess java or something)

ADD REPLY
0
Entering edit mode
3.8 years ago
Michael 55k

Decided to promote this to an answer, because the answer to your literal question is:

Do not use for-loops for parsing FASTA (or any line IO) files.


Which programming language should the depicted data structure be in or is that text output? Also, I think you need to specify the parsing problem properly first before jumping to the tool (for-loop). It is perfectly possible - and advisable - to parse fasta files without a for loop. A for loop is indeed an inefficient and error prone method of doing io parsing. Line IO parsing should not be done using for loops but alike unless you have a high-level Bio-API like BioPerl, BioPython, or R/Biostrings:

open IOstream as mystream; # obviously this is pseudocode
while (not EndOfFile(mystream)) {
  read some chunk from mystream;
  some operation;
}
close mystream; # if your language requires it

The reason is simply that a for loop requires to know the size of the file beforehand, first it is unnecessary to first go and count the number of lines, then more importantly there are "files" of which you don't know the size beforehand. With such files (pipes, streams, temporary files) you could not start processing chunks of the file until the file is completely written. Most of the time, fasta files can be processed entry by entry and you can be completely agnostic of what type of IO stream, file or pipe you are reading from. Instead use high-level API's or Stream-compatible file IO API in your language.

ADD COMMENT

Login before adding your answer.

Traffic: 2272 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6