@@ -17,7 +17,8 @@ import ProteinFinderService from "../services/protein.finder.service.js";
1717import GoFinderService from "../services/go.finder.service.js" ;
1818import AvgDegreeService from "../services/avg.degree.service.js" ;
1919import PGStats from "../services/pro.go.stats.service.js" ;
20- import Degree from "../services/degree.service.js" ;
20+ import PhysicalDegree from "../services/physical.degree.service.js" ;
21+ import RegulatoryDegree from "../services/regulatory.degree.service.js" ;
2122import MotifService from "../services/motif.service.js" ;
2223
2324const router = new Router ( ) ;
@@ -151,12 +152,11 @@ router.post("/getProGoStats", jsonParser, async (req, res, next) => {
151152 }
152153} ) ;
153154
154-
155- router . post ( "/Degree" , jsonParser , async ( req , res , next ) => {
155+ router . post ( "/getPhysicalDegree" , jsonParser , async ( req , res , next ) => {
156156 try {
157157 const data = req . body ;
158158 const id = data . id . id ;
159- const DEG = new Degree ( getDriver ( ) ) ;
159+ const DEG = new PhysicalDegree ( getDriver ( ) ) ;
160160 const degrees = await DEG . getdegree ( id ) ;
161161 res . json ( degrees ) ;
162162 }
@@ -165,7 +165,20 @@ router.post("/Degree", jsonParser, async (req, res, next) => {
165165 }
166166} ) ;
167167
168- router . post ( "/Motif" , jsonParser , async ( req , res , next ) => {
168+ router . post ( "/getRegulatoryDegree" , jsonParser , async ( req , res , next ) => {
169+ try {
170+ const data = req . body ;
171+ const id = data . id . id ;
172+ const DEG = new RegulatoryDegree ( getDriver ( ) ) ;
173+ const degrees = await DEG . getDegree ( id ) ;
174+ res . json ( degrees ) ;
175+ }
176+ catch ( e ) {
177+ next ( e ) ;
178+ }
179+ } ) ;
180+
181+ router . post ( "/getMotif" , jsonParser , async ( req , res , next ) => {
169182 try {
170183 const data = req . body ;
171184 const nodeList = data . nodeList
@@ -230,10 +243,10 @@ router.post("/getQueryByPath", jsonParser, async (req, res, next) => {
230243 } else {
231244 //DO this to all GOterm
232245 let relType = [ "ProGo" ]
233- if ( ppi ) {
246+ if ( ppi ) {
234247 relType . push ( "ProProUndirected" )
235248 }
236- if ( regulatory ) {
249+ if ( regulatory ) {
237250 relType . push ( "Reg" )
238251 }
239252
@@ -316,10 +329,10 @@ router.post("/getQueryByNode", jsonParser, async (req, res, next) => {
316329 } ) ;
317330 } else {
318331 let relType = [ "ProGo" ]
319- if ( ppi ) {
332+ if ( ppi ) {
320333 relType . push ( "ProProUndirected" )
321334 }
322- if ( regulatory ) {
335+ if ( regulatory ) {
323336 relType . push ( "Reg" )
324337 }
325338 const allShortestPathsService = new AllShortestPathsService (
@@ -366,35 +379,35 @@ router.post("/getQueryByNode", jsonParser, async (req, res, next) => {
366379
367380router . get ( '/call-flask' , ( req , res ) => {
368381 const options = {
369- hostname : 'localhost' ,
370- port : 5000 ,
371- path : '/test' ,
372- method : 'GET'
382+ hostname : 'localhost' ,
383+ port : 5000 ,
384+ path : '/test' ,
385+ method : 'GET'
373386 } ;
374387
375388 const flaskReq = http . request ( options , ( flaskRes ) => {
376- let data = '' ;
377-
378- // A chunk of data has been received.
379- flaskRes . on ( 'data' , ( chunk ) => {
380- data += chunk ;
381- } ) ;
382-
383- // The whole response has been received. Print out the result.
384- flaskRes . on ( 'end' , ( ) => {
385- try {
386- const jsonData = JSON . parse ( data ) ;
387- res . json ( jsonData ) ;
388- } catch ( error ) {
389- console . error ( 'Error parsing JSON:' , error ) ;
390- res . status ( 500 ) . json ( { message : 'Error parsing JSON from Flask API' } ) ;
391- }
392- } ) ;
389+ let data = '' ;
390+
391+ // A chunk of data has been received.
392+ flaskRes . on ( 'data' , ( chunk ) => {
393+ data += chunk ;
394+ } ) ;
395+
396+ // The whole response has been received. Print out the result.
397+ flaskRes . on ( 'end' , ( ) => {
398+ try {
399+ const jsonData = JSON . parse ( data ) ;
400+ res . json ( jsonData ) ;
401+ } catch ( error ) {
402+ console . error ( 'Error parsing JSON:' , error ) ;
403+ res . status ( 500 ) . json ( { message : 'Error parsing JSON from Flask API' } ) ;
404+ }
405+ } ) ;
393406 } ) ;
394407
395408 flaskReq . on ( 'error' , ( error ) => {
396- console . error ( 'Error calling Flask API:' , error ) ;
397- res . status ( 500 ) . json ( { message : 'Error calling Flask API' } ) ;
409+ console . error ( 'Error calling Flask API:' , error ) ;
410+ res . status ( 500 ) . json ( { message : 'Error calling Flask API' } ) ;
398411 } ) ;
399412
400413 flaskReq . end ( ) ;
0 commit comments