Programm – die neusten Beiträge

Einzelne Zahlen aus txt-Dateien in Python einlesen?

Guten Tag.

Ich lerne zur Zeit Python an der Hochschule und arbeite mit Python 3.5. Bisher kam ich immer gut zurecht, doch nun haben wir eine Hausübung bekommen, die mir etwas Kopfzerbrechen bereitet.

Die Aufgabe ist folgende:

Lesen Sie aus der Datei unip-mini.dat.txt Zeile SQ die Länge aller Proteine in eine Liste. Plotten Sie die Liste als Histogramm mit 50 Balken.

Beispiel, wie so eine Zeile aussieht: SQ SEQUENCE 458 AA; 53921 MW; E46E5C85D7ACA139 CRC64;

Länge: 458

Wie man grundsätzlich Dateien in Python einliest, ist mir bekannt. Ich bin auch schon so weit, dass es nur diejenigen Zeilen einliest, die eben mit SQ beginnen. Allerdings möchte ich ja nur die Länge der Proteine in der Liste haben. Nun ist mein Problem, dass ich eben nicht weiß, wie ich es fertig stelle, dass lediglich die Länge in die Liste eingefügt wird.

Mein Code sieht bisher wie folgt aus:

    #!/usr/bin/python3

    import numpy as np
    import matplotlib.mlab as mlab
    import matplotlib.pyplot as plt

    def main():
        if os.path.isfile(sys.argv[1]) == False:
            print("Datei", sys.argv[1], "nicht gefunden")
            exit(0)
        with open(sys.argv[1]) as filetoread:
            lines = filetoread.readlines()
        seq = []

        for i in range(len(lines)):
            if(re.search('SQ   ', lines[i])):
                seq.append(lines[i])

        print(seq)


    if __name__ == "__main__":
        import sys
        import os
        import string
        main()

Könnte mir da vielleicht jemand helfen? Vielleicht gehe ich die Sache ja gerade auch einfach ganz falsch an und merke es nicht.

Mit freundlichen Grüßen

Programm, programmieren, Bioinformatik, Informatik, Python

Organigram Excel mit einklappen und ausklappen (per Makro?)?

Hallo Zusammen,

etwas komplizierteres Problem hier: (zumindest bin ich nach stundenlangem Googeln auf englisch und deutsch auf kein akzeptables ergebis gekommen)

Im Prinzip klingt es einfach: Ich will ein Organigramm erstellen per Excel (Word wuerde auch noch gehen, keine sonstige Freeware da ich im Buero keine Software runterladen kann/darf). Nun will ich aber kein "statisches" Organigram (zb per SmartArt). Es soll eher so etwas sein wo ich auf einen Namen klicke und dann alle untergeordneten Leute/Mitarbeiter aufklappen (NUR DIE VON DEM JEWEILIGEN "BOSS").

Mit Gruppieren etc. komme ich nicht vorran da ich 1. will dass es per Mausklick auf den namen geht und 2. ich nicht mehr als 8 untergruppen erstellen kann damit.

Am liebsten auch ein Makro dass ich anpassen koennte ?Hab hier noch ein Bild was vllt etwas besser erklaert was ich meine.

Zum Bild:Ich will dann quasi dass am Anfang nur "CEO" da steht. Dann klicke ich zb auf "C" dann poppen 1,2,3,4,5 auf und ich klicke auf "1" dann poppen 11,12,13 auf etc.. der rest soll am besten verborgen bleiben (viel uebersichtlicher)

Hoffe, dass war einigermassen gut erklaert. Bei Fragen etc einfach nachfragen...Ich finde dazu leider auch wirklich nirgends etwas (ausser irgendwelcher Freeware etc.) Aber es MUSS doch moeglich sein?

Danke euch vieeelmals schonmal!!!

EDIT:

hab jetzt mal probiert einen Makro zu schreiben:

Sub collapse()

Selection.Offset(1, 1).Select
Range(Selection, Selection.End(xlDown)).

Select Selection.EntireRow.Hidden = True

End Sub

_______

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Target.Column = 2 Then

Target.Select

Call collapse

End If

If Target.Address = "$B$10" Then

Target.Select

Call collapse

End If

End Sub

____

Problem: Wenn ich es mit "target.column" mache (was mir lieber ist) dann wuerde ich gerne haben dass er bei leeren zellen nichts macht in dieser spalte... wie geht das genau? und hat einer eine ahnung wie ich das hinkrieg dass wenn ich WIEDER auf die gleiche zelle gehe er mir des rueckgaengig macht? Ich hab so eine ahnugn mit true/false denke ich mal aber habe keine ahnung wie ich das umsetzen kann..

Also irgendwie dass wenn ich einmal draufdruecke und des eingeklappt ist er weiss visibile = false oder sowas und wenn ich wieder draufdruecke soll er halt true machen versteht ihr mich :D?

Bild zum Beitrag
PC, Microsoft Word, Microsoft, Office, Microsoft Excel, Programm, programmieren, VBA

wie berechne ich das Produkt eines Arrays?

Ich habe echt alle jetzt hinbekommen aber jetzt fehlt mir das Produkt ich wollte das so machen

int produkt = 0;

produkt *= Array[i]; system.out... (produkt);

aber da kommt immer ein Fehler in der console undzwar :** Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at Array.main(Array.java:36) 0**

hier erstmal mein Code import java.util.Scanner;

public class Array {

public static void main(String[] args)
{
    // TODO Auto-generated method stub
    {
        Scanner input=new Scanner(System.in);
        int summe=0;
       

        System.out.print("Wie groß soll das Array sein?");
        int Arraygroeße=input.nextInt();

        int Array[]=new int[Arraygroeße]; // erstellt ein Array mit der
                                          // Größe
                                          // die man eingibt

        int i;
        for (i=0; i<Array.length; i++)
        {
            System.out.print("Feldwert an Stelle "+i+" eingeben: ");
            Array[i]=input.nextInt(); // soll den Wert einlesen den der
                                      // Nutzer
                                      // haben möchte bis das ganze Array
                                      // ausgefüllt ist
        }

        for (i=0; i<Array.length; i++)



            summe+=Array[i];
        System.out.println("Die Summe ist :"+summe);

        int max=Array[0];
        for (i=0; i<Array.length; i++)
            if (max<Array[i])
                max=Array[i];

        System.out.println("Größter Wert des Arrays ist "+max);

        int min=Array[0];
        for (i=0; i<Array.length; i++)
            if (min>Array[i])
                min=Array[i];

        System.out.println("Kleiner Wert des Array ist "+min);

        double mittel=0; // Mittelwert auf 0 setzen
        mittel=summe/Array.length; // Mittelwert berechnen durch Summe
                                   // geteielt durch die Anzahl der Zahlen
                                   // im Array
        System.out.println("Der Mittelwert beträgt:  "+mittel);
        
       
        input.close();

    }
  }
}

kann mir jemand bitte helfen wie ich das Produkt berechnen kann ? ( Java)

PC, Computer, Programm, programmieren, Java, Praktikum

Gerade seltsame E-Mail bekommen brauche dringend hilfe?

Ich habe gerade eine seltsame E-Mail bekommen auf Englisch im Titel war Hello Dear Ich habe eine Yahoo E-Mail In der E-Mail Stand dann das hier:

Hello Dear,

Please I want you to exercise some patience reading through this mail enable you have good understanding, meanwhile I will appreciate you to ignore and delete this mail from your mail box if you are not interested beeing my partner for the investment project in your country, meanwhile I got your email contact from Google from people chamber of commerce while I was searching for a reliable and honest person that will partner with me for the investment project to whose ever it may concern country.

Please permit me to introduce myself My names are Aisha Gaddafi, 37, years the only biological daughter of late Libya president Gaddafi, I want to use this opportunity to inform you that I need a very honest and reliable person that can help me look for a profitable business/ company to invest into there in your country then you let me know while and provide account where I can transfer the sum of$27.200.000.00 us d for the investment in your country Note you will have 30% of the total funds after the transfer of the funds to your account while I will further the process of the investment with remaining balance Please I will like to hear from you about the nature of the business to invest the money with and your experience, even if you are not interested in the business if you can assure me that my funds will be save once it is transferred into your account then you will still have the 30% of the total funds the sum $27.200.000.00 dollars About me.

The Gulf state has apparently turned a blind eye to the controversial pasts of family members wanted back home for squandering the wealth and privilege we enjoyed during the reign of my late father Colonel Gaddafi, who was deposed and killed in 2011 This is why I travel down to this country Burkina Faso where I deposited the $27.200.000.00 us dollars looking for a trust worthy and honest person that have a very good experience in any good business where I can invest the funds that will turns good profit enable me to carry on with my life and my 3 kids I will be waiting to hear from you with good positive respond urgently concerning this issue enable us to proceed further without any delay it is not good to continue suffering with my kids as a widow

Yours faithfully

Aisha Gaddafi

Jetzt meine Frage was ist das für eine E-Mail und habe ich jetzt einen Virus oder so was ich habe angst was jetzt mit meinem Laptop passiert ich habe ein Acer Aspiere E 17 mit Windows 8.1

Als Antivirusprogramm habe ich AVG Pro und also auch E-Mail Schutz

Und die E-Mail habe ich in Thunderbird geöffnet

Was ist das für eine E-Mail ???

PC, Computer, Internet, Gefahr, Windows, Technik, Virus, Programm

Meistgelesene Beiträge zum Thema Programm