<<KnotTheory`

CG[K_PD]:=Module[{k,kk,A,AA,B,BB,a,aa,b,bb,n=Length[K]},
k=K/.X[i_,j_,k_,l_]:>If[TrueQ[Mod[i,2]==0],X[i,j,k,l],X[l,i,j,k]];
A=k//.X[i_,j_,k_,l_]:> P[i,j]P[k,l];
B=k//.X[i_,j_,k_,l_]:>P[l,i]P[j,k];
a=(Times@@A)//.P[i_,j_]P[j_,k_]:> P[i,k];
b=(Times@@B)//.P[i_,j_]P[j_,k_]:> P[i,k];

kk=K/.X[i_,j_,k_,l_]:>If[TrueQ[Mod[i,2]==0],X[l,i,j,k],X[i,j,k,l]];
AA=kk//.X[i_,j_,k_,l_]:> P[j,i]P[l,k];
BB=kk//.X[i_,j_,k_,l_]:>P[i,l]P[k,j];
aa=(Times@@AA)//.P[i_,j_]P[j_,k_]:> P[i,k];
bb=(Times@@BB)//.P[i_,j_]P[j_,k_]:> P[i,k];Cases[{(1/2)(n-Length[a]-Length[b]+2),(1/2)(n-Length[aa]-Length[bb]+2)},_Integer][[1]]]

This now uses oriented paths.

Same program to convert Gauss codes.

GCtoPD[K_]:=Module[{j,l=Length@Characters[K]/3},
i[j_]:=(StringPosition[K,StringReplace["On","n"-> TextString[j]]][[1]][[1]]-1)/3+1;
p[j_]:=If[StringContainsQ[K,StringReplace["On+","n"-> TextString[j]]], i[j],n[j]+1];
n[j_]:=If[StringContainsQ[K,StringReplace["On-","n"-> TextString[j]]], i[j],p[j]+1];PD@@Table[X[(t-1)/3+1,Mod[n[Characters[K][[t+1]]],l,1],Mod[(t-1)/3+2,l,1],Mod[p[Characters[K][[t+1]]],l,1]],{t,Union@Flatten@StringPosition[K,"U"]}]]

Program that computes the genus in general.

genus[K_PD]:=Module[{k,kk,n=Length[K]},
k=K//.X[i_,j_,k_,m_]:>P[-i,Mod[j-m,n,-1] m]P[Mod[j-m,n,-1] j,i]P[k,-Mod[j-m,n,-1] j]P[-Mod[j-m,n,-1] m,-k];
kk=(Times@@k)//.P[i_,j_]P[j_,k_]:> P[i,k] ;
(1/2)(n-Length[kk]+2)]
genus[K_String]:=genus@GCtoPD[K]

A knot can be represented as a knotoid if it contains a cycle that goes around both sides of an edge (that is, a P that has some n and - n), and it has genus 1, or if it has genus 0.

cycles[K_PD]:=Module[{k,n=Length[K]},
k=K//.X[i_,j_,k_,m_]:>P[-i,Mod[j-m,n,-1] m]P[Mod[j-m,n,-1] j,i]P[k,-Mod[j-m,n,-1] j]P[-Mod[j-m,n,-1] m,-k];
(Times@@k)//.P[i___,j_]P[j_,k___]:> P[i,j,k] 
]

k416=PD[X[2,8,3,1],X[4,1,5,2],X[6,3,7,4],X[5,8,6,7]]

cycles[k416]

k444=PD[X[2,8,3,1],X[5,1,6,2],X[7,3,8,4],X[4,7,5,6]]

cycles[k444]