Morphisms of quasi-affine varieties and locally closed sub-varieties The Problem
Let $\varphi:X\to Y$ be a morphism of quasi-affine varieties. Let $Z\subset X$ be a locally closed sub-variety (that is, $Z$ is an open sub variety of a closed subvariety). Show that $\varphi|_Z:Z\to Y$ is also a morphism.
Necessary Definitions
A quasi-affine variety is a topological space $X$ together with an algebra of $\mathbb{C}$-valued functions $\mathcal{O}(X)$ such that: 


*

*There is a homeomorphism $\psi:X\to U_X$ where $U_X$ is an open subset of an algebraic set in $\mathbb{C}^n$ for some $n$.

*The induced algebra homomorphism $\psi^*:\mathcal{O}(U_X)\to \mathcal{O}(X)$ is an isomorphism of $\mathbb{C}$-algebras.
A morphism of quasi-affine varieties is a map $\Psi:X\to Y$ between quasi-affine varieties such that for every $f\in \mathcal{O}(Y)$, $f\circ \Psi\in \mathcal{O}(X)$.
Discussion
My first observation is that we should be able to reduce the problem to the case where $X$ and $Y$ are open subsets of algebraic sets, i.e. we can replace them by $U_X$ and $U_Y$ and suppose that $\varphi:U_X\to U_Y.$ (Although I don't know if this should be necessary)
My biggest problem with this question is that I don't know what exactly the ring of functions $\mathcal{O}(Z)$ should be for a locally closed subset $Z$ of $U_X$.
Abusing notation I will write $X$ for the algebraic set $U_X$ belongs to and $Y$ for the one $U_Y$ belongs to. I do know how to describe $\mathcal{O}(U_X)$ (or more generally the $\mathcal{O}(U)$ for an open subset $U$ of an algebraic set):

$f:U_X\to \mathbb{C}$ belongs to $\mathcal{O}(U_X)$ if there exists an open cover $\{U_i\}$ of $U_X$ such that on $U_i$, $f=g_i/h_i$ with $g_i,h_i\in \mathcal{O}(X)$ and $h_i(x)\neq 0$ for all $x\in U_i$.

Since $\varphi:U_X\to U_Y$ is a morphism, for all $f\in \mathcal{O}(U_Y)$, $f\circ \varphi\in \mathcal{O}(U_X)$, that is, there exists an open cover $\{U_i\}$ of $U_X$ such that on $U_i$, $f\circ \varphi=g_i/h_i$ with $g_i,h_i\in \mathcal{O}(X)$ and $h_i(x)\neq 0$ for all $x\in U_i$ (*). 
Let $Z=U\cap X'$  where $U$ is an open sub-variety of $U_X$ and $X'$ is a closed sub-variety. By $(*)$ we have that for all $f\in \mathcal{O}(U_Y)$, 
there is a cover $Z=\cup_i V_i$ (With $V_i=U_i\cap U\cap X'$) such that on $V_i$, 
 $f\circ \varphi|_Z=g_i/h_i$ with $g_i,h_i\in \mathcal{O}(X)$ and $h_i(x)\neq 0$ for all $x\in V_i$ 
Is this equvialent to saying $f\circ \varphi|_Z$ belongs to $\mathcal{O}(Z)$? This depends on how $\mathcal{O}(Z)$ is characterized, and this I am unsure of.
Maybe someone has some insight into this?
 A: Let's say that $Z$ is an open subscheme of a closed subscheme $Z'$ of $X$, sended to $Y$ by $\varphi$. The local model for all of this is : $\textrm{Spec}\left( (B/J)_{(f)} \right) \rightarrow \textrm{Spec}\left( B/J \right) \rightarrow \textrm{Spec}\left( B \right) \rightarrow \textrm{Spec}\left( A \right)$ where $(B/J)_{(f)}$ is the usual localisation and $f$ denote the image of $f$ in $B/J$. This situation comes from the ring morphism $A \rightarrow (B/J)_{(f)}$, where $A\rightarrow B$ corresponds to $\varphi$ by the spectrum functor, and therefore the restriction is perfectly defined in this case. The global case results from patching.
A: Acting on a comment I made earlier, I would like to provide an answer to this problem using only the definitions referred to in the original post, i.e. without using the language of schemes or sheaves (which I was not familiar with at the time of posting the original problem). I think this is worthwhile as the problem proves to be quite a valuable resource for showing certain maps between quasi-affine (and affine) varieties are morphisms. I apologize for the delayed response.
Preliminaries
Those familiar with the variety structure on a locally closed subset of a quasi-affine variety should skip to the claim below.
Let $\varphi:X\to Y$ be a morphism of quasi-affine varieties, and let $Z=U\cap W$ with $W\subset X$ a closed subset and $U\subset X$ open. The key to proving this result is to better understand what kind of variety structure $Z$ has and where it comes from. This is best seen in two steps:


*

*$W\subset X$ is itself is a quasi-affine variety. 

*Any open subset of a quasi-affine variety is a quasi affine variety. Thus, since $Z\subset W$ is open, Z inherits the structure of a quasi-affine variety. 


Step 1 follows from the general observation that any closed subset $W$ of a quasi-affine variety $X$ is itself a quasi-affine variety with function ring $\mathcal{O}(W)$ given by restriction of function. That is, $f:W\to k$ belongs to $\mathcal{O}(W)$ if there is a collection of open subsets $\{V_i\}_{i\in I}$ in $X$ that cover $W$ together with functions $\{g_i\}_{i\in I}$ such that $g_i\in \mathcal{O}(V_i)$ and $f|_{W\cap V_i}={g_i}|_{W \cap V_i}$.
Step 2 has already been observed in the original post: an open subset $Z$ of a quasi-affine variety $W$ is again a quasi affine variety with function ring consisting of functions $f:Z\to k$ such that locally $f$ is a quotient of regular functions in $\mathcal{O}(W)$ $(*)$.
Thus $(Z,\mathcal{O}(Z))$ is a quasi-affine variety. We now prove the result: 
Proof of Statement

Claim: $\varphi|_Z:Z\to Y$ is a morphism.

Let $f\in \mathcal{O}(Y)$. We show $(\varphi|_Z)^*(f)\in \mathcal{O}(Z)$. First note that by definition of $\mathcal{O}(W)$, $(f\circ \varphi)|_W\in\mathcal{O}(W)$. Indeed since $\varphi$ is a morphism $f\circ \varphi\in \mathcal{O}(X)$, so $(f\circ \varphi)|_W$ is the restriction of a regular function on $X$ to $W$, and so belongs to $\mathcal{O}(W)$. 
Now let $g:=(f\circ \varphi)|_W\in \mathcal{O}(W)$. Then on all of $Z$ we have:
$$(\varphi|_Z)^*(f)=f\circ (\varphi|_Z)=(f\circ \varphi)_Z=\left( (f\circ \varphi)|_W\right)|_Z=g|_Z.$$ 
Thus, by definition of $\mathcal{O}(Z)$, $(\varphi|_Z)^*(f)\in \mathcal{O}(Z)$. To really nail this in: $(\varphi|_Z)^*(f)$ is globally on $Z$ given by $\frac{g}{1}$ with $g\in\mathcal{O}(W)$, and so satisfies definition $(*)$. This proves that $\varphi|_Z$ is a morphism. 
