2bit extraction

1,228 views
Skip to first unread message

Joachim Berger

unread,
Jan 8, 2018, 11:50:49 AM1/8/18
to gen...@soe.ucsc.edu
Hi,
I am trying to extract a 2bit file with twoBitToFa. However the twoBitToFa command is not recognised by the utility. How do I extract 2bit file?
Thank you very much for your help.
Best regards,
Joe

--
Joachim Berger

Ph.D., M.Sc. in Chemistry, M.Sc. in Biology
Senior Research Fellow
Australian Regenerative Medicine Institute
EMBL Australia
15 Innovation Walk (building 75)
Monash University, Clayton Campus
Clayton, VIC 3800, Australia
Ph.: +61 (0)3 9902 9621
Fax: +61 (0)3 9905 9862

Cath Tyner

unread,
Jan 8, 2018, 8:48:24 PM1/8/18
to Joachim Berger, UCSC Genome Browser Public Help Forum
Hi Joachim,

Thanks for contacting the UCSC Genome Browser support team. I'll go through some basic troubleshooting below, 
listing details that you may already be familiar with - but others may search for this issue in the future, so I'll be specific :)

From your command line, can you just type "twoBitToFa" (note the case sensitivity) and press enter? If you run the name 
of the utility on the command-line with no arguments, you should be able to see the usage statement as such:

$twoBitToFa

twoBitToFa - Convert all or part of .2bit file to fasta
usage:
   twoBitToFa input.2bit output.fa
options:
   -seq=name       Restrict this to just one sequence.
   -start=X        Start at given position in sequence (zero-based).
   -end=X          End at given position in sequence (non-inclusive).
   -seqList=file   File containing list of the desired sequence names
                   in the format seqSpec[:start-end], e.g. chr1 or chr1:0-189
                   where coordinates are half-open zero-based, i.e. [start,end).
   -noMask         Convert sequence to all upper case.
   -bpt=index.bpt  Use bpt index instead of built-in one.
   -bed=input.bed  Grab sequences specified by input.bed. Will exclude introns.
   -bedPos         With -bed, use chrom:start-end as the fasta ID in output.fa.
   -udcDir=/dir/to/cache  Place to put cache for remote bigBed/bigWigs.

Sequence and range may also be specified as part of the input
file name using the syntax:
      /path/input.2bit:name
   or
      /path/input.2bit:name
   or
      /path/input.2bit:name:start-end

If you are able to run the usage statement, then this means the permissions and path is working for you. 

If the above test doesn't work, try doing a "cd" into the directory where your utility is. Make sure that you 
have executable permissions by typing the following command:

$chmod +x <filename>

It's possible that the directory in which your utility resides is not listed in your $PATH. Once you are in the 
directory where the utility resides, type the following (note the "dot slash") to see if you can get the usage statement.

$ ./twoBitToFa

Note that you can either add the location of the utility to your bash PATH environment variable, 
or you can specify the path when you run it from a different directory. 

One other thing to check is that you are using the correct utility version by typing "uname -a" 
on the command line and pressing enter:

For example,

$ uname -a
Linux hgwdev 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Then make sure you have selected the correct utility version, starting here:

Here is an example usage statement:

twoBitToFa input.2bit output.fa

For example, you can download the hg38 2.bit file here:

With a command such as this (note the 'dot' at the end to put the file in your current directory):

rsync -avzP rsync://hgdownload.cse.ucsc.edu/goldenPath/hg38/bigZips/hg38.2bit  .

You can now try one of the following commands:

If you can get the usage statement by simply typing/entering the utility (without the preceding  'dot slash'), try this:

twoBitToFa hg38.2bit hg38.output.fa

Or, if you need to specify where your utility is, try this (from the directory where your 2bit and utility both reside):

./twoBitToFa hg38.2bit hg38.output.fa

If on the other hand, you are trying to make a 2bit from a fasta file, you will need to use this utility instead: faToTwoBit.
faToTwoBit

Command usage:

faToTwoBit in.fa [in2.fa in3.fa ...] out.2bit

Example:

faToTwoBit in.fa hg38.fa hg38.outputFromFasta.2bit

If these steps still do not assist in attaining your goal, please respond to this forum with the following details:

1. What is the exact command you are using?
2. Can you provide information regarding the input files you are using?

Please respond to this list if you have further questions, and please always feel free to search our mailing list archives for related posts.

Thank you for contacting the UCSC Genome Browser support team. 
Please send new and follow-up questions to one of our mailing lists below:

  * Post to the Public Help Forum: E
mail 
gen...@soe.ucsc.edu
​ or search the Public Archives
​  * Post to the Mirror Help Forum: Email
 
genome...@soe.ucsc.edu 
or search the Mirror Archives​
​  * Confidential/private help: Email
 
genom...@soe.ucsc.edu

Join us on Social Media! FacebookTwitter, Wordpress BlogYouTube
UCSC Genome Browser Announcements List (for new data & software)
Request on-site training & workshops at your institution

​Enjoy,​
Cath
. . .
Cath Tyner
UCSC Genome Browser, Software QA & User Support
UC Santa Cruz Genomics Institute


--

---
You received this message because you are subscribed to the Google Groups "UCSC Genome Browser Public Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genome+un...@soe.ucsc.edu.
To post to this group, send email to gen...@soe.ucsc.edu.
Visit this group at https://groups.google.com/a/soe.ucsc.edu/group/genome/.
To view this discussion on the web visit https://groups.google.com/a/soe.ucsc.edu/d/msgid/genome/CAERomdjxmS0cS7bdUb2XQt0c5_JAzJ9-O%3D4Dtu%3Dtmo6qg-zwWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/soe.ucsc.edu/d/optout.

Cath Tyner

unread,
Jan 9, 2018, 1:54:04 PM1/9/18
to Joachim Berger, UCSC Genome Browser Public Help Forum
Hello again Joe,

Thank you for responding with the screenshot and details, that is helpful!

The easiest thing to do here might be to remove your current utility and do a clean download - this way we can ensure that you are using the correct version.
Before trying the steps below, note that the name of utility is case sensitive. If you are able to get the usage statement with the command "./twobitofa" then that indicates to me that you have renamed the utility from its original name, "twoBitToFa" and you will need to use whatever exact name you have renamed the utility as when issuing your command.

For example, you may want to try the following command:

./twobitofa danRer11.2bit danRer11.output.fa

Or, if you would like to do a fresh install of the utility to make sure it is the correct version, use the steps below:

1. cd into the directory where you want to install the utility

2. copy/paste/enter this command (note the 'dot' at the end)

rsync -aP rsync://hgdownload.cse.ucsc.edu/genome/admin/exe/macOSX.x86_64/twoBitToFa .

3. change the permissions to make the utility executable:

chmod +x twoBitToFa

4. Without downloading anything else, you can try this test command, which will access the 2bit on our download server directly:
Note the "./" in front to indicate that the utility is in the current directory (issue this command from the same directory where your utility resides).

./twoBitToFa -seq=chr1 -start=1499900 -end=1500055 http://hgdownload.soe.ucsc.edu/gbdb/hg38/hg38.2bit output.fa

Sidenote: You can always issue the find command to see the exact location of your utility.

For example, if the utility is on your desktop, and you are in another directory, say that you are in the dir /Users/Joe

$find . -name twoBitToFa
./Desktop/twoBitToFa

You would then issue the command from /Users/Joe:
​ (note the preceding dot)​

./Desktop/twoBitToFa -seq=chr1 -start=1499900 -end=1500055 http://hgdownload.soe.ucsc.edu/gbdb/hg38/hg38.2bit output.fa

Or, if you cd to Desktop:

cd Desktop

​...​
you would use the preceding " dot slash" to indicate that the utility is in the current directory (in this example, your Desktop):

./twoBitToFa -seq=chr1 -start=1499900 -end=1500055 http://hgdownload.soe.ucsc.edu/gbdb/hg38/hg38.2bit output.fa

One
​ way to avoid this confusion is to always put utilities in a certain directory, suc
h as
/Users/
​Joe/bin

and then simply add this path to your path variable in your .bashrc file.

Do a "cd" to get to your home dir, 
then see if you have a file called .bashrc:

ls .bashrc

If so, edit it. If not, create it:

vi .bashrc

add this line: 
(press "i" to go to insert mode)
​, where "Joe" should be changed to your actual location of your bin dir:​

export PATH="/Users/
​Joe
/bin/:$PATH"

In vi, ​save the file (press "esc" to go to command mode, then press 'shift and ZZ' to save the file and close).
Then reload it:

source .bashrc && clear

​You should now be able to get the usage statement from your utility, if it is saved in the 'bin' directory, by just typing the name of the utility. ​

Cath
. . .
Cath Tyner
UCSC Genome Browser, Software QA & User Support
UC Santa Cruz Genomics Institute

On Mon, Jan 8, 2018 at 8:06 PM, Joachim Berger <joachim...@monash.edu> wrote:
Dear Cath,

I am afraid that I am still stuck. As you can see from my attached picture, I activated TwoBitToFa with the chmod command and can also see the usage statement. I also think that I am running the correct version of TwoBitToFa for my Mac, which runs on Mac OS 10.12.6. However, though I have the files danRer.2bit and also hg38.2bit in the same folder together with TwoBitToFa, I get the error message: "twoBitToFa: command not found".

Thank you very much for your help in advance.

Best regards,
Joe
Reply all
Reply to author
Forward
0 new messages