Counting rods; count your rods Some background

Counting rods are small bars (3-14 cm long) that were used by mathematicians from many asian cultures for more than 2000 years to represent any whole number or fraction. (In this chqllenge we'l focus on unsigned integers though) There was also a written version, called rod numerals.

Here's how it works:

(If at any point you get confused, go check out the ascii representation of each digit and some examples I have included at the bottom)

Rod numerals are a true positional numeral system with digits for 1-9 and blank for 0.
The digits consist of horizontal and vertical lines; the more lines, the higher the digit. Once you get past five, you put a horizontal line on top to add 5 to the numer of lines below.
One vertical line is 1, two vertical lines 2, five vertical lines is 5, one vertical line with a horizontal line on top is 6, four vertical lines with a horizontal line on top is 9 (the highest digit).

A vertical 3 digit:

 ||| 
 ||| 
 ||| 
 ||| 
 ||| 


To make reading rod numerals easier though, they used different notation for each alternating digit. The second notation swaps the role of the horizontal and vertical lines. so that 3 is represented by three horizontal lines and 8 by three horizontal lines with a vertical line on top.

A horizontal 8 digit:

  |  
  |  
__|__
_____
_____


Knowing which notation to use is easy, as previously said, tehy are used alternatingly and Sun Tzu wrote that "one is vertical, ten is horizontal". So the rightmost digit is vertical and we alternate from there on.

The challenge

These rods were used to represent negative numbers and fractions (as explained in the wikipedia article on them. For the purpose of this challenge we'll only focus on positive integers though. The objective is simple:

Write a function or full program that takes an integer value as input in any way and prints the rod numeral representation of this integer to STDOUT (you may also write to a file if that works out better). Shortest code in bytes wins.

Every digit will be represented by 5x5 ascii characters and seperated by two collumns of 5 spaces. The exact representation you'll use for each digit is as follows:

space between two digits (two colums):





0 digit, both vertical and horizontal (five columns):






1 digit, vertical:
  |  
  |  
  |  
  |  
  |  

2 digit, vertical:  
 | | 
 | | 
 | | 
 | | 
 | | 

3 digit, vertical:
 ||| 
 ||| 
 ||| 
 ||| 
 ||| 

4 digit, vertical:
|| ||
|| ||
|| ||
|| ||
|| ||

5 digit, vertical:
|||||
|||||
|||||
|||||
|||||

6 digit, vertical:
_____
  |  
  |  
  |  
  |  

7 digit, vertical:
_____
 | | 
 | | 
 | | 
 | | 

8 digit, vertical:
_____
 ||| 
 ||| 
 ||| 
 ||| 

9 digit, vertical:
_____
|| ||
|| ||
|| ||
|| ||

1 digit, horizontal:




_____

2 digit, horizontal:



_____
_____

3 digit, horizontal:


_____
_____
_____

4 digit, horizontal:

_____
_____
_____
_____

5 digit, horizontal:
_____
_____
_____
_____
_____

6 digit, horizontal:
  |  
  |  
  |  
  |  
__|__

7 digit, horizontal:
  |  
  |  
  |  
__|__
_____

8 digit, horizontal:
  |  
  |  
__|__
_____
_____

9 digit, horizontal:
  |  
__|__
_____
_____
_____


The digits are to be printed next to each other. Trailing spaces beyond the bounding box of the last digit are not allowed. Trailing spaces to complete the bounding box of the last digit(s) are required. You should end the output with a single trailing newline. Leading spaces that do not belong to the bounding box of the first digit are also forbidden.

Standard loopholes apply.

Example output

Lines starting with &gt; are to be interpreted as input.

&gt;12
        | | 
        | | 
        | | 
        | | 
_____   | | 

&gt;8037
  |                  _____
  |                   | | 
__|__         _____   | | 
_____         _____   | | 
_____         _____   | | 

&gt;950
_____  _____       
|| ||  _____       
|| ||  _____       
|| ||  _____       
|| ||  _____
Python 2 - 216
My first shot, might be some stuff to take out, but my brain hurts, so it's good enough for now
x=raw_input()
for l in range(5):print'  '.join((' '*7+'|   | |  ||| || '+'|'*7+'__|'+'_'*7)[[7*(4-l&lt;n%6+n/6)+(n&gt;5)*(l&lt;10-n)-(l==10-n),n%6+n/6+(l&lt;1)*(n&gt;5)*(12-n)][(len(x)-i)%2]*5:][:5]for i,n in enumerate(map(int,x)))