How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.R. Jha Your Own Question

R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5444
Experience:  B.Tech
20870358
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

HELP Please! Need Pseudo code for array comparison in Python

Resolved Question:

Attachment: 2013-05-02_122655_pseudo_code_for_later_implementation_in_python.docx

I have a list of data (array) from an experiment:


v1 = 23, -1, -3, ..., n


v2 = 12, 0, -26, ..., n


- - -


vn = -1, -1, 1, ..., n


 


and


 


p1 = 3, -11, 3, ..., n


p2 = 1, 0, 6, ..., n


- - -


pn = -1, 1, 1, ..., n


 


Have to normalize all values to 0 and 1 first:


if value is<=0 make value=0; if value>0 make value=1


 


After normalize, compare using Boolean logic, the vn lists with the pn list.


pn ALWAYS as result of vn boolean interactions, returning true or false as ouput.


I have to compare the whole list... not element by element...


Have to use only these booleans == (equal to), != (not equal to), and 'and'.


Final results should be something like:


v1 = pn; v2 is not pn; vn and v2 and ... = pn


 


Optional Information:
Language (or Software): Python
Browser (if necessary): Safari


 


Already did:



  1. # XXXXX data in array (list) format where vnj contains gene expression from DNA microarray for a vn gene at time j (t input), and pnj contains gene expression from DNA microarray for a vn gene at time j (t+1 output)

  2. Use variables: v1, v2, v3, ..., vn, p1, p2, p3, ..., pn

  3. # XXXXX normalization to an integer in binary format (0, 1).

  4. # XXXXX is the number of columns/genes (i), and k is the maximum number of rows (j).

  5. for i=1 to n

  6. for j=0 to k

  7. if vij<=0 then vij=0 otherwise make vij=1

  8. if pij<=0 then pij=0 otherwise make pij=1

  9. done


13. done


14.


15. # XXXXX Boolean logic compare all elements in vn with all elements in pn. Return vn "inhibits" or "activates" pn.


16.


17. for i=1 to n


18. for j=1 to n


19. if vi==pj then print vi,' activates ',pj


20. if vi!=pj then print vi,' inhibits ',pj


21. *** MISSING "AND" COMPARISON ***


22.


23. done


24. done

Submitted: 1 year ago.
Category: Homework
Expert:  Josie-Mod replied 1 year ago.
Hi, I'm a Moderator for this topic. I've been working hard to find a professional to assist you right away, but sometimes finding the right professional can take a little longer than expected.


I wonder whether you're ok with continuing to wait for an answer. If you are, please let me know and I will continue my search. If not, please let me know and I will cancel this question for you. Thank you!
Customer: replied 1 year ago.
Thanks, XXXXX XXXXX wait.
It doesn't need be someone super expert... I just would like to have someone with python experience to give me some inputs.
I have no rush to have it finished.
Thanks
Expert:  Josie-Mod replied 1 year ago.
Thank you for your continued patience. We will continue the search for a professional for you.
Expert:  R.R. Jha replied 1 year ago.
Hi,

I'd be glad to help with your question. Could you please explain with example, how should the AND comparison be? Are you ANDing all vi's and checking if it's equal to pj?
Customer: replied 1 year ago.

Thank you RRJha,


I need is the relationship of pj (the output) from vi (the input)...


I am attaching a table to see it can be more explanatory...


I did some extra work too...


If you could have a look, it would be very helpful.


No rush...


 

Customer: replied 1 year ago.

I am trying to attach the table, but it gives me error...


 


Below it is what I did so far:


 



  1. start


  2. # XXXXX data in array (list) format where vnj contains gene expression from DNA microarray for a vn gene at time j (t input), and pnj contains gene expression from DNA microarray for a vn gene at time j (t+1 output)


  3. Use variables: v1, v2, v3, ..., vn, p1, p2, p3, ..., pn


  4. # XXXXX normalization to an integer in binary format (0, 1).

  5. # XXXXX is the number of columns/genes (i), and k is the maximum number of rows (j).


  6. for i=1 to n

  7. for j=0 to k

  8. if vij<=0 then vij=0 otherwise make vij=1

  9. if pij<=0 then pij=0 otherwise make pij=1

  10. done

  11. done


  12. # XXXXX Boolean logic to compare all vn lists with all pn lists. Return vn "inhibits" or "activates" pn.


  13. for i=1 to n

  14. for j=1 to n

  15. if vi==pj then print vi,' activates ',pj

  16. if vi!=pj then print vi,' inhibits ',pj

  17. done

  18. done


  19. for all vn, if (vn and vn) == pn print vn,' and ', vn,' activates ',pn

  20. for all vn, if (vn and vn) != pn print vn,' and ', vn,' inhibits ',pn


  21. end

Customer: replied 1 year ago.

The number of pns are equal to the number of vns.


You can think vns as v1(t), v2(t),..., vn(t)


and pns as v1(t+1), v2(t+1),...,vn(t+1)


 


Relationship Boolean:


 


NOT (pn is not true for vn):


v p


1 0


0 1


 


AND (example: vn and vn are true for pn)


vn vn pn


1 1 1


1 0 0


0 1 0


0 0 0


 


Let me know if you need more information.


 


Thanks again

Expert:  R.R. Jha replied 1 year ago.
Could you please clarify more about the AND relationship you're looking for? I know how AND works, but not sure what combination are you looking for. Do you want to check each pi against all possible ANDing combination of vi's?
Because == and != logic would compare only one vi against one pi, but AND can take multiple combination of vi's and compare it with one pi.

For example, checking

v1 AND v2 == p1
v1 AND v2 AND v3 == p1
v2 AND v5 == p2
v3 AND v5 AND v7 == p3

So, what AND combination are you looking to compare with a pi? I hope I'm making it clear what my question is.

Thanks
Customer: replied 1 year ago.

Yes, you are right.


All combinations possibles for v... I got stuck on there...


 

Expert:  R.R. Jha replied 1 year ago.
Ok, I'll give it a try and let you know.
Customer: replied 1 year ago.

Thanks for your help.

Expert:  R.R. Jha replied 1 year ago.
You're welcome
Expert:  R.R. Jha replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5444
Experience: B.Tech
R.R. Jha and 12 other Homework Specialists are ready to help you
Customer: replied 1 year ago.
Thank you!

Your work looks great. I will be implementing the python code during the fall semester. For sure I will need your help.

Thanks again.

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience