1 / 18

Sequence formats

Sequence formats. Say we get this protein sequence in fasta format from a database:. >FOSB_MOUSE Protein fosB. 338 bp MFQAFPGDYDSGSRCSSSPSAESQYLSSVDSFGSPPTAAASQECAGLGEMPGSFVPTVTA ITTSQDLQWLVQPTLISSMAQSQGQPLASQPPAVDPYDMPGTSYSTPGLSAYSTGGASGS

ling
Download Presentation

Sequence formats

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sequence formats Say we get this protein sequence in fasta format from a database: >FOSB_MOUSE Protein fosB. 338 bp MFQAFPGDYDSGSRCSSSPSAESQYLSSVDSFGSPPTAAASQECAGLGEMPGSFVPTVTA ITTSQDLQWLVQPTLISSMAQSQGQPLASQPPAVDPYDMPGTSYSTPGLSAYSTGGASGS GGPSTSTTTSGPVSARPARARPRRPREETLTPEEEEKRRVRRERNKLAAAKCRNRRRELT DRLQAETDQLEEEKAELESEIAELQKEKERLEFVLVAHKPGCKIPYEEGPGPGPLAEVRD LPGSTSAKEDGFGWLLPPPPPPPLPFQSSRDAPPNLTASLFTHSEVQVLGDPFPVVSPSY TSSFVLTCPEVSAFAGAQRTSGSEQPSDPLNSPSLLAL Now we need to compare this sequence to all sequences in some other database. Unfortunately this database uses the phylip format, so we need to translate: Phylip Format: The first line of the input file contains the number of sequences and their length (all should have the same length) separated by blanks. The next line contains a sequence name, next lines are the sequence itself in blocks of 10 characters. Then follow rest of sequences.

  2. Sequence formats Fasta Phylip >FOSB_MOUSE Protein fosB. 338 bp MFQAFPGDYDSGSRCSSSPSAESQYLSSVDSFGSPPTAAASQECAGLGEMPGSFVPTVTA ITTSQDLQWLVQPTLISSMAQSQGQPLASQPPAVDPYDMPGTSYSTPGLSAYSTGGASGS GGPSTSTTTSGPVSARPARARPRRPREETLTPEEEEKRRVRRERNKLAAAKCRNRRRELT DRLQAETDQLEEEKAELESEIAELQKEKERLEFVLVAHKPGCKIPYEEGPGPGPLAEVRD LPGSTSAKEDGFGWLLPPPPPPPLPFQSSRDAPPNLTASLFTHSEVQVLGDPFPVVSPSY TSSFVLTCPEVSAFAGAQRTSGSEQPSDPLNSPSLLAL So we copy and paste and reformat the sequence: and all is well. Then our boss says “Do it for these 5000 sequences.” 1 338 FOSB_MOUSE MFQAFPGDYD SGSRCSSSPS AESQYLSSVD SFGSPPTAAA SQECAGLGEM PGSFVPTVTA ITTSQDLQWL VQPTLISSMA QSQGQPLASQ PPAVDPYDMP GTSYSTPGLS AYSTGGASGS GGPSTSTTTS GPVSARPARA RPRRPREETL TPEEEEKRRV RRERNKLAAA KCRNRRRELT DRLQAETDQL EEEKAELESE IAELQKEKER LEFVLVAHKP GCKIPYEEGP GPGPLAEVRD LPGSTSAKED GFGWLLPPPP PPPLPFQSSR DAPPNLTASL FTHSEVQVLG DPFPVVSPSY TSSFVLTCPE VSAFAGAQRT SGSEQPSDPL NSPSLLAL

  3. We need automatic filter! • A program that reads any number of fasta sequences and converts them into phylip format (want to run sequences through a filter) • Program structure: • Open fasta file • Parse file to extract needed information • Create and save phylip file • We will use this definition for the fasta format: • The header starts with > • The word immediately following the ">" is a unique ID; next two words are the name of the sequence, the rest of the header is a description. • All lines of text are shorter than 80 characters.

  4. Pseudo-code fasta→phylip filter • Open and parse fasta file • From each header extract sequence ID and name • Open phylip file • Write “1” followed by sequence length • Write sequence ID • Write sequence in blocks of 10 • Close file

  5. The other way too: pseudo-code phylip→fasta filter • Open phylip file • Find first non-empty line, ignore! • Parse next line and extract first word (sequence ID) • Read rest of line and following lines to get the sequence, skipping blanks • Read next sequences • Open fasta file, and for each sequence: • Write “>” followed by sequence name • Write sequence in lines of 80 • Close files

  6. More formats? phylip-fasta • Boss: “Great! What about EMBL and GDE formats?” Coding, coding,.. : 12 filters! phylip fasta fasta - phylip

  7. Still more formats? • Boss: “Super. And Genebank and ClustalW..?” Coding, coding, coding, ..: 30 filters  • Next new format = 12 new filters! • This doesn’t scale.

  8. Intermediate format • Use an internal format as intermediate step: • Two formats: four filters phylip-internal phylip internal-phylip internal internal-fasta fasta - internal fasta

  9. Intermediate format • Six formats: 12 filters (not 30) • New format: always two new filters only i-format

  10. Let’s build a structured set of filters! • Each x2internal filter module: parse file in x format, extract information, return sequence(s) in internal format • Each internal2y filter module: save i-format sequences in (separate) file(s) in y format • Example: Overall phylip-fasta filter: • import phylip2i and i2fasta modules • obtain filenames to load from and save to from command line • call parse_file method of the phylip2i module • call the save_to_files method of the i2fasta module

  11. Internal representation of a sequence Attributes: type (DNA/protein), name, and a unique ID number Isequence.py (part 1)

  12. Isequence.py (part 2)

  13. Example: fasta/phylip filter First fasta2internal. Each x2internal filter module: parse file in x format, extract information, return sequence(s) in internal format fasta2i.py

  14. Then internal2phylip. Each internal2y filter module: save each i-format sequence in separate file in y format i2phylip.py

  15. Putting the parts together: Fasta/phylip filter • Import parse_file method from fasta2i module • Import save_to_files method from i2phylip module • Obtain filenames to load from and save to from command line • Call parse_file method • Call the save_to_files method fasta2phylip.py NB: nothing in code about phylip and fasta below this point..

  16. Sketch for i2embl filter module Use i2phylip filter as template, much of the code can be reused. NB: Same method name save_to_files Only these parts have to be rewritten

  17. Complete fasta/embl filter (assuming we have the i2embl filter..) Almost the same code as the fasta2phylip filter: only change is that the method save_to_files is imported from new module fasta2embl.py

  18. .. on to the exercises

More Related