Q:

Given a natural number $a$ find its index in a set of structural descriptions

Looking at orbits of the collatz-like $(5x+1)/2^X$ - map I come to a useful structural description for all odd integers $a$.
If I write $$ {5a+1 \over 2^A} \to b \qquad \qquad \text{for odd positive } a,b \tag 1$$ 
then I get the following pattern where parameters $k \ge 0$, $B \ge 0$ are integers
$$ \begin{array} {rrcl}
 \text{pattern}&\text{structure of a} & \to &\text{structure of b} \\
 \hline \\
 p_1:& ( 3 + 32k) \cdot 16^B+ 3[B]_{16} & \to & 1+10k  \\
 p_3:& ( 1 +  4k) \cdot 16^B+ 3[B]_{16} & \to & 3+10k \\
 p_7:& (11 + 16k) \cdot 16^B+ 3[B]_{16} & \to & 7+10k \\
 p_9:& ( 7 +  8k) \cdot 16^B+ 3[B]_{16} & \to & 9+10k \\
 \end{array} \tag 2
$$
Here the $\displaystyle [B]_{16}= { 16^B-1\over 16-1}$ is the q-analogue of the $B$'th power to base 16.
Letting in the a-structure the parameters $k$ and $B$ vary over the natural numbers I should represent the whole set of odd positive integers.
Also, the cofactor at $k$ in "structure of a" is a power of $2$, and if we write the terms, for instance the first one
$$ (3+2^C \cdot 2k) \cdot 16^B+ 3[B]_{16} \tag 3$$
then the value $A$ in (1) is $A=C+4B$        
Now my question is to "invert" that useful table:     
Q1: Given an positive odd number $a$ - how can I practically determine which pattern $p_1,p_3,p_7,p_9$ it belongs to? (This means to find the values for the parameters $B$ and $k$)    
[update]: (remark) I've separated the unfortunate double-use of the parameter $A$ in (1) and (2) in the original post to $A$ in (1) and $B$ in (2)

A:

Eventually I want a more mathematical idea, but for the moment I'm fine having a procedural possibility to get $B$ and $k$ from a given $a$.        
Here is a procedure in Pari/GP; simple after the key-idea: just use the transformation of $a \to b$ to find all requested parameters.
$$ \small \begin{array} {} 
   a_1 & = & 5a+1 \\
   A & = & \operatorname{valuation}(a_1,2) &  \text{// gives the exponent of 2 in the primefactorization of } z \\
   b & = & a_1/2^A \\
 \hline \\
   B & = & \lfloor (A-1) / 4 \rfloor \\
   k & = & \lfloor b/10 \rfloor \\
 \hline \\
   & & \text{ Now check the formula using the}&\text{parameters: }\\
   r_b & = & b \operatorname{mod} 10 \\
   r_a&=& [3,0,1,0,0,0,11,0,7][r_b] &  \text{// $r_b \in \{1,3,7,9\}$ is the index into a vector of residuals} \\
   C &=& [4,0,1,0,0,0, 3,0,2][r_b] &  \text{//     ... and of exponents } C \\
   x & = & (r_a + 2^C \cdot 2k)\cdot 16^B + 3{16^B-1 \over 16-1} & \text{// this should equal $a$: } a=x
\end{array}$$
It comes out to be correct in a sequence of tests (using Pari/GP) 

