SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
What program(s) made these output files? gringer Bioinformatics 1 08-09-2012 07:33 PM
Blastn cannot open .nin files PlutonicFriend Bioinformatics 1 07-24-2012 12:37 PM
open *.sh files. dror Bioinformatics 1 11-14-2010 03:45 AM
Google spreadsheet for NGS stats avilella General 5 03-09-2010 12:20 PM
Any program to extract different peaks from two wigs files hon Bioinformatics 1 10-29-2009 01:30 AM

Reply
 
Thread Tools
Old 12-10-2013, 09:37 AM   #1
KnowNothing2
Member
 
Location: Raleigh NC

Join Date: Sep 2013
Posts: 49
Default What linux spreadsheet program can you open .sam files in?

Tried opening it in libre office calc but the program just freezes
KnowNothing2 is offline   Reply With Quote
Old 12-10-2013, 10:04 AM   #2
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,888
Default

Are we talking about an alignment file? Why do you want to open it in a spreadsheet program? If you need to make a change there may be an alternate option available.
GenoMax is offline   Reply With Quote
Old 12-10-2013, 10:12 AM   #3
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Well, you can probably open it in libre office if it's small enough (it does read it into memory). Why you would actually want to do that is beyond me.
dpryan is offline   Reply With Quote
Old 12-10-2013, 10:17 AM   #4
KnowNothing2
Member
 
Location: Raleigh NC

Join Date: Sep 2013
Posts: 49
Default

Quote:
Originally Posted by dpryan View Post
Well, you can probably open it in libre office if it's small enough (it does read it into memory). Why you would actually want to do that is beyond me.
Basically to write a program
KnowNothing2 is offline   Reply With Quote
Old 12-10-2013, 10:28 AM   #5
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

You really don't want to write macros to deal with data of this size. Try python/perl/C/whatever. You can use R, if you prefer, but I think it usually reads everything into memory too.
dpryan is offline   Reply With Quote
Old 12-10-2013, 10:51 AM   #6
KnowNothing2
Member
 
Location: Raleigh NC

Join Date: Sep 2013
Posts: 49
Default

Quote:
Originally Posted by dpryan View Post
You really don't want to write macros to deal with data of this size. Try python/perl/C/whatever. You can use R, if you prefer, but I think it usually reads everything into memory too.
I'm actually trying to write in python. How do I notate a certain variable in a sam file (I'm very new to python bioinformatics).
KnowNothing2 is offline   Reply With Quote
Old 12-10-2013, 10:58 AM   #7
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Generally something like the following will work:

Code:
import csv

sam = csv.reader(open("foo.sam","r"), dialect="excel-tab")
for line in sam :
    print("QNAME: %s" % (line[0]))
    print("Sequence: %s" % (line[9]))
So, just use the column number. You can also use pysam, which makes some things much easier. If you're comfortable with C, I can also recommend the samtools C API. If you need higher performance, you'll find it quite useful.
dpryan is offline   Reply With Quote
Old 12-10-2013, 11:03 AM   #8
KnowNothing2
Member
 
Location: Raleigh NC

Join Date: Sep 2013
Posts: 49
Default

Quote:
Originally Posted by dpryan View Post
Generally something like the following will work:

Code:
import csv

sam = csv.reader(open("foo.sam","r"), dialect="excel-tab")
for line in sam :
    print("QNAME: %s" % (line[0]))
    print("Sequence: %s" % (line[9]))
So, just use the column number. You can also use pysam, which makes some things much easier. If you're comfortable with C, I can also recommend the samtools C API. If you need higher performance, you'll find it quite useful.
So that's basically exactly what I was looking for. Thanks!
KnowNothing2 is offline   Reply With Quote
Old 12-10-2013, 11:25 AM   #9
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Glad I could help. BTW, I didn't deal with the header in my example. You might check "if(len(line) > 5): stuff" or check for a @ as the first character to get past the header (unless you want to parse it).
dpryan is offline   Reply With Quote
Old 12-10-2013, 11:29 AM   #10
KnowNothing2
Member
 
Location: Raleigh NC

Join Date: Sep 2013
Posts: 49
Default

Quote:
Originally Posted by dpryan View Post
Glad I could help. BTW, I didn't deal with the header in my example. You might check "if(len(line) > 5): stuff" or check for a @ as the first character to get past the header (unless you want to parse it).
Right, I'll have to figure out some of the details. Right now, I just have an idea what I want to perform, but no real idea how to execute. But I did just read through a tutorial that kind of went over the sort of info you presented, I was just unaware that you could do this directly to a sam file.
KnowNothing2 is offline   Reply With Quote
Old 12-10-2013, 01:29 PM   #11
LeightonP
Member
 
Location: Scotland

Join Date: Feb 2011
Posts: 29
Default

You might want to consider the pysam module: http://wwwfgu.anat.ox.ac.uk/~andreas...tools/api.html and https://code.google.com/p/pysam/

(EDIT: I see Devon already suggested this - apologies for the duplication0

Last edited by LeightonP; 12-10-2013 at 01:30 PM. Reason: Noticed duplication of advice.
LeightonP is offline   Reply With Quote
Old 12-11-2013, 02:13 AM   #12
lindenb
Senior Member
 
Location: France

Join Date: Apr 2010
Posts: 143
Default Visualize Bam

FYI: I wrote a simple java-based GUI to visualize some BAMS: https://github.com/lindenb/jvarkit/wiki/BamViewGui

lindenb is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 09:55 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO